Repository: symfony/symfony
File: src/Symfony/Component/Lock/Store/DoctrineDbalStore.php (PHP)

Code before:
    /**
     * Cleans up the table by removing all expired locks.
     */
    private function prune(): void
    {
        $sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}";

        $this->conn->executeStatement($sql);
    }

    /**
     * Provides an SQL function to get the current timestamp regarding the current connection's driver.
     */
    private function getCurrentTimestampStatement(): string
    {
        $platform = $this->conn->getDatabasePlatform();

        return match (true) {
            $platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform => 'UNIX_TIMESTAMP()',
            $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => 'strftime(\'%s\',\'now\')',
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform => 'CAST(EXTRACT(epoch FROM NOW()) AS DOUBLE PRECISION)',
            $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => '(SYSDATE - TO_DATE(\'19700101\',\'yyyymmdd\'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600',
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => 'DATEDIFF(s, \'1970-01-01\', GETUTCDATE())',
            default => (string) time(),
        };
    }

    /**
     * Checks whether current platform supports table creation within transaction.
     */
    private function platformSupportsTableCreationInTransaction(): bool
    {
        $platform = $this->conn->getDatabasePlatform();

        return match (true) {
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform,
            $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => true,
            default => false,
        };
    }
}


Review comment (refactor):
Let's provide the same precision on other platforms then:


```suggestion
            $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform => 'UNIX_TIMESTAMP(NOW(6))',
            $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => "(julianday('now') - 2440587.5) * 86400.0",
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform => 'CAST(EXTRACT(epoch FROM NOW()) AS DOUBLE PRECISION)',
            $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => "(CAST(systimestamp AT TIME ZONE 'UTC' AS DATE) - DATE '1970-01-01') * 86400 + TO_NUMBER(TO_CHAR(systimestamp AT TIME ZONE 'UTC', 'SSSSS.FF'))",
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => "CAST(DATEDIFF_BIG(ms, '1970-01-01', SYSUTCDATETIME()) AS FLOAT) / 1000.0",
            default => (new \DateTimeImmutable())->format('U.u'),
```

Code after:
    /**
     * Cleans up the table by removing all expired locks.
     */
    private function prune(): void
    {
        $sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}";

        $this->conn->executeStatement($sql);
    }

    /**
     * Provides an SQL function to get the current timestamp regarding the current connection's driver.
     */
    private function getCurrentTimestampStatement(): string
    {
        $platform = $this->conn->getDatabasePlatform();

        return match (true) {
            $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform,
            $platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform => 'UNIX_TIMESTAMP(NOW(6))',
            $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => "(julianday('now') - 2440587.5) * 86400.0",
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform,
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform => 'CAST(EXTRACT(epoch FROM NOW()) AS DOUBLE PRECISION)',
            $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => "(CAST(systimestamp AT TIME ZONE 'UTC' AS DATE) - DATE '1970-01-01') * 86400 + TO_NUMBER(TO_CHAR(systimestamp AT TIME ZONE 'UTC', 'SSSSS.FF'))",
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform => "CAST(DATEDIFF_BIG(ms, '1970-01-01', SYSUTCDATETIME()) AS FLOAT) / 1000.0",
            default => (new \DateTimeImmutable())->format('U.u'),
        };
    }

    /**
     * Checks whether current platform supports table creation within transaction.
     */
    private function platformSupportsTableCreationInTransaction(): bool
    {
        $platform = $this->conn->getDatabasePlatform();

        return match (true) {
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform,
            $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform,
            $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform => true,
            default => false,
        };
    }
}