diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 952e51424b53..723a07c32eff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,18 @@ jobs: - php: 8.2 phpunit: '12.4.0' include: + - php: 8.5 + phpunit: '12.1.0' + stability: prefer-stable + - php: 8.5 + phpunit: '12.2.0' + stability: prefer-stable + - php: 8.5 + phpunit: '12.3.0' + stability: prefer-stable + - php: 8.5 + phpunit: '12.4.0' + stability: prefer-stable - php: 8.3 phpunit: '12.1.0' stability: prefer-stable @@ -119,6 +131,18 @@ jobs: - php: 8.2 phpunit: '12.4.0' include: + - php: 8.5 + phpunit: '12.1.0' + stability: prefer-stable + - php: 8.5 + phpunit: '12.2.0' + stability: prefer-stable + - php: 8.5 + phpunit: '12.3.0' + stability: prefer-stable + - 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 1f9c0b186f15..a11b2b076097 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": "^10.8.0", "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..8298041ee1b8 100644 --- a/config/database.php +++ b/config/database.php @@ -61,7 +61,7 @@ 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + (PHP_VERSION_ID >= 80500 ? Pdo\Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], @@ -81,7 +81,7 @@ 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + (PHP_VERSION_ID >= 80500 ? Pdo\Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], diff --git a/src/Illuminate/Cache/RedisTagSet.php b/src/Illuminate/Cache/RedisTagSet.php index 82369ff4ed00..cbb4dee0732a 100644 --- a/src/Illuminate/Cache/RedisTagSet.php +++ b/src/Illuminate/Cache/RedisTagSet.php @@ -48,12 +48,18 @@ public function entries() $cursor = $defaultCursorValue; do { - [$cursor, $entries] = $connection->zscan( + $results = $connection->zscan( $this->store->getPrefix().$tagKey, $cursor, ['match' => '*', 'count' => 1000] ); + if (! is_array($results)) { + break; + } + + [$cursor, $entries] = $results; + if (! is_array($entries)) { break; } diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index c5671fefc5f1..e6586edd7f95 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -844,10 +844,10 @@ public static function mapSpread(array $array, callable $callback) * * @param array $array * @param mixed $value - * @param array-key $key + * @param mixed $key * @return array */ - public static function prepend($array, $value, $key = '') + public static function prepend($array, $value, $key = null) { if (func_num_args() == 2) { array_unshift($array, $value); diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 08a852fe19fa..8c0673e453fd 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -1033,7 +1033,7 @@ public function pop($count = 1) */ public function prepend($value, $key = null) { - $this->items = Arr::prepend($this->items, ...func_get_args()); + $this->items = Arr::prepend($this->items, ...(func_num_args() > 1 ? func_get_args() : [$value])); return $this; } diff --git a/src/Illuminate/Database/Connectors/Connector.php b/src/Illuminate/Database/Connectors/Connector.php index a40bd2c6b861..8d0af49a9ae0 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 version_compare(PHP_VERSION, '8.4.0', '<') ? 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/Schema/MySqlSchemaState.php b/src/Illuminate/Database/Schema/MySqlSchemaState.php index 427c943ff736..9c922a6e580e 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -111,7 +111,8 @@ protected function connectionString() ? ' --socket="${:LARAVEL_LOAD_SOCKET}"' : ' --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}"'; - if (isset($config['options'][\PDO::MYSQL_ATTR_SSL_CA])) { + /** @phpstan-ignore class.notFound */ + if (isset($config['options'][PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA])) { $value .= ' --ssl-ca="${:LARAVEL_LOAD_SSL_CA}"'; } @@ -140,7 +141,7 @@ protected function baseVariables(array $config) 'LARAVEL_LOAD_USER' => $config['username'], 'LARAVEL_LOAD_PASSWORD' => $config['password'] ?? '', 'LARAVEL_LOAD_DATABASE' => $config['database'], - 'LARAVEL_LOAD_SSL_CA' => $config['options'][\PDO::MYSQL_ATTR_SSL_CA] ?? '', + 'LARAVEL_LOAD_SSL_CA' => $config['options'][PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA] ?? '', // @phpstan-ignore class.notFound ]; } diff --git a/tests/Cache/RedisCacheIntegrationTest.php b/tests/Cache/RedisCacheIntegrationTest.php index d2e4b23fa0e7..aafa46a0404d 100644 --- a/tests/Cache/RedisCacheIntegrationTest.php +++ b/tests/Cache/RedisCacheIntegrationTest.php @@ -11,9 +11,11 @@ use Illuminate\Support\Env; use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Redis; +#[RequiresPhpExtension('redis')] class RedisCacheIntegrationTest extends TestCase { use InteractsWithRedis; @@ -166,6 +168,10 @@ public function testItFailsWithAnInvalidPhpRedisAlgorithm() public static function phpRedisBackoffAlgorithmsProvider() { + if (! class_exists(Redis::class)) { + return []; + } + return [ ['default', Redis::BACKOFF_ALGORITHM_DEFAULT], ['decorrelated_jitter', Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER], diff --git a/tests/Database/DatabaseMariaDbSchemaStateTest.php b/tests/Database/DatabaseMariaDbSchemaStateTest.php index fff911093b5b..d1342027319b 100644 --- a/tests/Database/DatabaseMariaDbSchemaStateTest.php +++ b/tests/Database/DatabaseMariaDbSchemaStateTest.php @@ -63,7 +63,7 @@ public static function provider(): Generator 'username' => 'root', 'database' => 'forge', 'options' => [ - \PDO::MYSQL_ATTR_SSL_CA => 'ssl.ca', + PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA => 'ssl.ca', ], ], ]; diff --git a/tests/Database/DatabaseMySqlSchemaStateTest.php b/tests/Database/DatabaseMySqlSchemaStateTest.php index 08603621275f..e1b4be9f9eca 100644 --- a/tests/Database/DatabaseMySqlSchemaStateTest.php +++ b/tests/Database/DatabaseMySqlSchemaStateTest.php @@ -65,7 +65,7 @@ public static function provider(): Generator 'username' => 'root', 'database' => 'forge', 'options' => [ - \PDO::MYSQL_ATTR_SSL_CA => 'ssl.ca', + PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA => 'ssl.ca', ], ], ]; diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index aae771cd2a17..d47d2879614c 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -9,6 +9,7 @@ use Illuminate\Support\ItemNotFoundException; use Illuminate\Support\MultipleItemsFoundException; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; use stdClass; use WeakMap; @@ -164,6 +165,7 @@ public function testCrossJoin() $this->assertSame([[]], Arr::crossJoin()); } + #[IgnoreDeprecations] public function testDivide(): void { // Test dividing an empty array @@ -187,7 +189,7 @@ public function testDivide(): void $this->assertEquals(['first', 'second'], $values); // Test dividing an array with null key - [$keys, $values] = Arr::divide(['' => 'Null', 1 => 'one']); + [$keys, $values] = Arr::divide([null => 'Null', 1 => 'one']); $this->assertEquals([null, 1], $keys); $this->assertEquals(['Null', 'one'], $values); @@ -200,6 +202,11 @@ public function testDivide(): void [$keys, $values] = Arr::divide(['' => ['one' => 1, 2 => 'second'], 1 => 'one']); $this->assertEquals([null, 1], $keys); $this->assertEquals([['one' => 1, 2 => 'second'], 'one'], $values); + + // Test dividing an array where the values are arrays (with null key) + [$keys, $values] = Arr::divide([null => ['one' => 1, 2 => 'second'], 1 => 'one']); + $this->assertEquals([null, 1], $keys); + $this->assertEquals([['one' => 1, 2 => 'second'], 'one'], $values); } public function testDot() @@ -1036,6 +1043,7 @@ public function testMapSpread() $this->assertEquals(['1-a-0', '2-b-1'], $result); } + #[IgnoreDeprecations] public function testPrepend() { $array = Arr::prepend(['one', 'two', 'three', 'four'], 'zero'); @@ -1047,6 +1055,9 @@ public function testPrepend() $array = Arr::prepend(['one' => 1, 'two' => 2], 0, ''); $this->assertEquals(['' => 0, 'one' => 1, 'two' => 2], $array); + $array = Arr::prepend(['one' => 1, 'two' => 2], 0, null); + $this->assertEquals([null => 0, 'one' => 1, 'two' => 2], $array); + $array = Arr::prepend(['one', 'two'], null, ''); $this->assertEquals(['' => null, 'one', 'two'], $array); @@ -1061,6 +1072,18 @@ public function testPrepend() $array = Arr::prepend(['one', 'two'], ['zero'], 'key'); $this->assertEquals(['key' => ['zero'], 'one', 'two'], $array); + + $array = Arr::prepend(['one', 'two'], ['zero'], ''); + $this->assertEquals(['one', 'two', '' => ['zero']], $array); + + $array = Arr::prepend(['one', 'two', '' => 'three'], ['zero'], ''); + $this->assertEquals(['one', 'two', '' => ['zero']], $array); + + $array = Arr::prepend(['one', 'two'], ['zero'], null); + $this->assertEquals(['one', 'two', null => ['zero']], $array); + + $array = Arr::prepend(['one', 'two', '' => 'three'], ['zero'], null); + $this->assertEquals(['one', 'two', null => ['zero']], $array); } public function testPull() diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 7438266c855c..fff1be0b7543 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -20,6 +20,7 @@ use JsonSerializable; use Mockery as m; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; use ReflectionClass; use stdClass; @@ -4215,6 +4216,7 @@ public function testPaginate($collection) $this->assertEquals([], $c->forPage(3, 2)->all()); } + #[IgnoreDeprecations] public function testPrepend() { $c = new Collection(['one', 'two', 'three', 'four']); @@ -4234,6 +4236,12 @@ public function testPrepend() [null => 0, 'one' => 1, 'two' => 2], $c->prepend(0, null)->all() ); + + $c = new Collection(['one' => 1, 'two' => 2]); + $this->assertEquals( + [null => 0, 'one' => 1, 'two' => 2], + $c->prepend(0, '')->all() + ); } public function testPushWithOneItem()