diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 952e51424b53..ffc4f8d33dd8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,9 @@ jobs: - php: 8.2 phpunit: '12.4.0' include: + - php: 8.5 + phpunit: '12.4.0' + stability: prefer-stable - php: 8.3 phpunit: '12.1.0' stability: prefer-stable @@ -119,6 +122,9 @@ jobs: - php: 8.2 phpunit: '12.4.0' include: + - php: 8.5 + phpunit: '12.4.0' + stability: prefer-stable - php: 8.3 phpunit: '12.1.0' stability: prefer-stable diff --git a/composer.json b/composer.json index 3cd0043c01e2..1c9095ca33a3 100644 --- a/composer.json +++ b/composer.json @@ -115,7 +115,7 @@ "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", "opis/json-schema": "^2.4.1", - "orchestra/testbench-core": "^10.7.0", + "orchestra/testbench-core": "dev-10/php85 as 10.999.999", "pda/pheanstalk": "^5.0.6|^7.0.0", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", diff --git a/config/database.php b/config/database.php index 1d9883833e62..5254446e353c 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,7 @@ true, 'strict' => true, 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], + 'options' => MySqlConnector::features([ + 'ATTR_SSL_CA' => env('MYSQL_ATTR_SSL_CA'), + ]), ], 'mariadb' => [ @@ -80,9 +82,9 @@ 'prefix_indexes' => true, 'strict' => true, 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], + 'options' => MariaDbConnector::features([ + 'ATTR_SSL_CA' => env('MYSQL_ATTR_SSL_CA'), + ]), ], 'pgsql' => [ diff --git a/src/Illuminate/Database/Connectors/Connector.php b/src/Illuminate/Database/Connectors/Connector.php index a40bd2c6b861..242a802e6d65 100755 --- a/src/Illuminate/Database/Connectors/Connector.php +++ b/src/Illuminate/Database/Connectors/Connector.php @@ -62,7 +62,7 @@ public function createConnection($dsn, array $config, array $options) */ protected function createPdoConnection($dsn, $username, #[\SensitiveParameter] $password, $options) { - return version_compare(phpversion(), '8.4.0', '<') + return PHP_VERSION_ID < 80400 ? new PDO($dsn, $username, $password, $options) : PDO::connect($dsn, $username, $password, $options); /** @phpstan-ignore staticMethod.notFound (PHP 8.4) */ } diff --git a/src/Illuminate/Database/Connectors/MySqlConnector.php b/src/Illuminate/Database/Connectors/MySqlConnector.php index fc55b801407f..38e7621120f0 100755 --- a/src/Illuminate/Database/Connectors/MySqlConnector.php +++ b/src/Illuminate/Database/Connectors/MySqlConnector.php @@ -2,10 +2,30 @@ namespace Illuminate\Database\Connectors; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; use PDO; class MySqlConnector extends Connector implements ConnectorInterface { + /** + * Determine of PDO feature constant. + * + * @param array $features + * @return array + */ + public static function features(array $features) + { + if (! extension_loaded('pdo_mysql')) { + return []; + } + + return (new Collection($features)) + ->mapWithKeys(fn ($value, $feature) => [(string) Str::of($feature)->prepend(PHP_VERSION_ID < 80400 ? 'PDO::MYSQL_' : 'Pdo\Mysql::') => $value]) + ->filter() + ->all(); + } + /** * Establish a database connection. * diff --git a/src/Illuminate/Database/Connectors/SQLiteConnector.php b/src/Illuminate/Database/Connectors/SQLiteConnector.php index 858549ec55de..205930f13d26 100755 --- a/src/Illuminate/Database/Connectors/SQLiteConnector.php +++ b/src/Illuminate/Database/Connectors/SQLiteConnector.php @@ -3,9 +3,29 @@ namespace Illuminate\Database\Connectors; use Illuminate\Database\SQLiteDatabaseDoesNotExistException; +use Illuminate\Support\Collection; +use Illuminate\Support\Str; class SQLiteConnector extends Connector implements ConnectorInterface { + /** + * Determine of PDO feature constant. + * + * @param array $features + * @return array + */ + public static function features(array $features) + { + if (! extension_loaded('pdo_sqlite')) { + return []; + } + + return (new Collection($features)) + ->mapWithKeys(fn ($value, $feature) => [(string) Str::of($feature)->prepend(PHP_VERSION_ID < 80400 ? 'PDO::SQLITE_' : 'Pdo\Sqlite::') => $value]) + ->filter() + ->all(); + } + /** * Establish a database connection. *