From a40c658fb4599a5623c2248d085eb4e145b6a8f5 Mon Sep 17 00:00:00 2001 From: Maarten Buis Date: Mon, 1 Jan 2024 15:03:04 +0100 Subject: [PATCH 01/32] Update ScheduleListCommandTest.php (#49541) --- .../Integration/Console/Scheduling/ScheduleListCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php index d5cca88cf50e..6507316223db 100644 --- a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php @@ -17,7 +17,7 @@ protected function setUp(): void { parent::setUp(); - Carbon::setTestNow('2023-1-1'); + Carbon::setTestNow('2023-01-01'); ScheduleListCommand::resolveTerminalWidthUsing(fn () => 80); $this->schedule = $this->app->make(Schedule::class); From ae79bf02349afa5eba33c0f0b661992641e9de18 Mon Sep 17 00:00:00 2001 From: Michael Nabil <46572405+michaelnabil230@users.noreply.github.com> Date: Mon, 1 Jan 2024 17:17:18 +0200 Subject: [PATCH 02/32] Clean Arr (#49530) --- src/Illuminate/Collections/Arr.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index c14465c6b3fa..d1e4a40ae686 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -476,9 +476,7 @@ public static function keyBy($array, $keyBy) */ public static function prependKeysWith($array, $prependWith) { - return Collection::make($array)->mapWithKeys(function ($item, $key) use ($prependWith) { - return [$prependWith.$key => $item]; - })->all(); + return static::mapWithKeys($array, fn ($item, $key) => [$prependWith.$key => $item]); } /** From a5f661f403bd52feff3dc5d25f55fb8f97b551cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Mon, 1 Jan 2024 16:19:51 +0100 Subject: [PATCH 03/32] [10.x] Make ComponentAttributeBag Arrayable (#49524) --- src/Illuminate/View/ComponentAttributeBag.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 3c3d1a27dbff..b5302e3e3ec4 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -4,6 +4,7 @@ use ArrayAccess; use ArrayIterator; +use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\Arr; use Illuminate\Support\HtmlString; @@ -14,7 +15,7 @@ use JsonSerializable; use Traversable; -class ComponentAttributeBag implements ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable +class ComponentAttributeBag implements Arrayable, ArrayAccess, IteratorAggregate, JsonSerializable, Htmlable { use Conditionable, Macroable; @@ -486,6 +487,16 @@ public function jsonSerialize(): mixed return $this->attributes; } + /** + * Convert the object into an array. + * + * @return array + */ + public function toArray() + { + return $this->attributes; + } + /** * Implode the attributes into a single HTML ready string. * From f8c636087a566309e7f50704440a7f512c71ff44 Mon Sep 17 00:00:00 2001 From: lovePizza Date: Mon, 1 Jan 2024 16:24:08 +0100 Subject: [PATCH 04/32] [10.x] Fix whenAggregated when default is not specified (#49521) * Fix: whenAggregated should return MissingValue when default is not specified * Test: whenAggregated should return MissingValue when default is not specified --- .../Http/Resources/ConditionallyLoadsAttributes.php | 4 ++++ tests/Integration/Http/ResourceTest.php | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php index 3f25ca052407..0eed09f27256 100644 --- a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php +++ b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php @@ -320,6 +320,10 @@ public function whenCounted($relationship, $value = null, $default = null) */ public function whenAggregated($relationship, $column, $aggregate, $value = null, $default = null) { + if (func_num_args() < 5) { + $default = new MissingValue; + } + $attribute = (string) Str::of($relationship)->snake()->append('_')->append($aggregate)->append('_')->finish($column); if (! isset($this->resource->getAttributes()[$attribute])) { diff --git a/tests/Integration/Http/ResourceTest.php b/tests/Integration/Http/ResourceTest.php index ab7bb0cd86cb..56cee847887c 100644 --- a/tests/Integration/Http/ResourceTest.php +++ b/tests/Integration/Http/ResourceTest.php @@ -502,8 +502,6 @@ public function testResourcesMayHaveOptionalRelationshipAggregates() 'data' => [ 'id' => 5, 'title' => 'Test Title', - 'average_rating' => null, - 'minimum_rating' => null, 'maximum_rating' => 'Default Value', ], ]); From 81b0c16f4e80f53a89ee8b31968c2109205c9bd2 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 1 Jan 2024 15:24:30 +0000 Subject: [PATCH 05/32] Apply fixes from StyleCI --- src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php index 0eed09f27256..9940c3e0cea6 100644 --- a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php +++ b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php @@ -323,7 +323,7 @@ public function whenAggregated($relationship, $column, $aggregate, $value = null if (func_num_args() < 5) { $default = new MissingValue; } - + $attribute = (string) Str::of($relationship)->snake()->append('_')->append($aggregate)->append('_')->finish($column); if (! isset($this->resource->getAttributes()[$attribute])) { From 38fa79eaa22b95446b92db222d89ec04a7ef10c7 Mon Sep 17 00:00:00 2001 From: pintend Date: Mon, 1 Jan 2024 10:37:06 -0500 Subject: [PATCH 06/32] Update AsArrayObject.php use ARRAY_AS_PROPS (#49534) --- src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php b/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php index 2ee6b56e0901..5ee80d0bb4f0 100644 --- a/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php +++ b/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php @@ -25,7 +25,7 @@ public function get($model, $key, $value, $attributes) $data = Json::decode($attributes[$key]); - return is_array($data) ? new ArrayObject($data) : null; + return is_array($data) ? new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS) : null; } public function set($model, $key, $value, $attributes) From 84d28db0bb6434e3fb75ce51ad8544db1c2c2221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 3 Jan 2024 05:57:39 -0800 Subject: [PATCH 07/32] don't call `CLIENT SETNAME` on cluster connection (#49560) --- src/Illuminate/Redis/Connectors/PhpRedisConnector.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php index d15b15cd31d8..72b7bcc8e065 100644 --- a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php +++ b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php @@ -199,10 +199,6 @@ protected function createRedisClusterInstance(array $servers, array $options) $client->setOption(RedisCluster::OPT_SLAVE_FAILOVER, $options['failover']); } - if (! empty($options['name'])) { - $client->client('SETNAME', $options['name']); - } - if (array_key_exists('serializer', $options)) { $client->setOption(Redis::OPT_SERIALIZER, $options['serializer']); } From f493ec577ea5164deb699780c72ac1d6dae30fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 3 Jan 2024 06:02:53 -0800 Subject: [PATCH 08/32] remove unused code (#49559) --- src/Illuminate/Redis/Connectors/PhpRedisConnector.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php index 72b7bcc8e065..06618a2ff118 100644 --- a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php +++ b/src/Illuminate/Redis/Connectors/PhpRedisConnector.php @@ -63,9 +63,7 @@ public function connectToCluster(array $config, array $clusterOptions, array $op */ protected function buildClusterConnectionString(array $server) { - return $this->formatHost($server).':'.$server['port'].'?'.Arr::query(Arr::only($server, [ - 'database', 'password', 'prefix', 'read_timeout', - ])); + return $this->formatHost($server).':'.$server['port']; } /** From 757848e60340e5da903a4776eeb2c34479d62f69 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 4 Jan 2024 01:05:21 +1100 Subject: [PATCH 09/32] [10.x] Flush about command during test runs (#49557) * Flush about command during test runs * Update name * Update TestCase.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Foundation/Console/AboutCommand.php | 12 ++++++++++++ src/Illuminate/Foundation/Testing/TestCase.php | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index b393c60f1d6a..20c24e8e7c11 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -302,4 +302,16 @@ protected function toSearchKeyword(string $value) { return (string) Str::of($value)->lower()->snake(); } + + /** + * Flush the registered about data. + * + * @return void + */ + public static function flushState() + { + static::$data = []; + + static::$customDataResolvers = []; + } } diff --git a/src/Illuminate/Foundation/Testing/TestCase.php b/src/Illuminate/Foundation/Testing/TestCase.php index b9b76bf2a50c..152b5c4131ae 100644 --- a/src/Illuminate/Foundation/Testing/TestCase.php +++ b/src/Illuminate/Foundation/Testing/TestCase.php @@ -6,6 +6,7 @@ use Illuminate\Console\Application as Artisan; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bootstrap\HandleExceptions; +use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; use Illuminate\Foundation\Http\Middleware\TrimStrings; use Illuminate\Queue\Queue; @@ -242,6 +243,7 @@ protected function tearDown(): void $this->originalExceptionHandler = null; $this->originalDeprecationHandler = null; + AboutCommand::flushState(); Artisan::forgetBootstrappers(); Component::flushCache(); Component::forgetComponentsResolver(); From 016ae04ff6b4aefae78e19c64d8271357d911406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Wed, 3 Jan 2024 15:07:01 +0100 Subject: [PATCH 10/32] [10.x] Fix parentOfParameter method (#49548) --- src/Illuminate/Routing/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Routing/Route.php b/src/Illuminate/Routing/Route.php index 7664500784f8..02518733300c 100755 --- a/src/Illuminate/Routing/Route.php +++ b/src/Illuminate/Routing/Route.php @@ -583,7 +583,7 @@ public function parentOfParameter($parameter) { $key = array_search($parameter, array_keys($this->parameters)); - if ($key === 0) { + if ($key === 0 || $key === false) { return; } From fa446dc78a17aaf922585a9b25b804181a451914 Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Thu, 4 Jan 2024 01:12:01 +1100 Subject: [PATCH 11/32] [10.x] Make the Schema Builder macroable (#49547) * make the schema builder macroable * stop passing the parameter to the closure. --- src/Illuminate/Database/Schema/Builder.php | 3 ++ .../Database/SchemaBuilderTest.php | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index c4b3da940265..770c6c52655c 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -5,11 +5,14 @@ use Closure; use Illuminate\Container\Container; use Illuminate\Database\Connection; +use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; use LogicException; class Builder { + use Macroable; + /** * The database connection instance. * diff --git a/tests/Integration/Database/SchemaBuilderTest.php b/tests/Integration/Database/SchemaBuilderTest.php index 7f3c8546881f..fbd42e13c489 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -384,4 +384,33 @@ public function testSystemVersionedTables() DB::statement('create table `test` (`foo` int) WITH system versioning;'); } + + public function testAddingMacros() + { + Schema::macro('foo', fn () => 'foo'); + + $this->assertEquals('foo', Schema::foo()); + + Schema::macro('hasForeignKeyForColumn', function (string $column, string $table, string $foreignTable) { + return collect(Schema::getForeignKeys($table)) + ->contains(function (array $foreignKey) use ($column, $foreignTable) { + return collect($foreignKey['columns'])->contains($column) + && $foreignKey['foreign_table'] == $foreignTable; + }); + }); + + Schema::create('questions', function (Blueprint $table) { + $table->id(); + $table->string('body'); + }); + + Schema::create('answers', function (Blueprint $table) { + $table->id(); + $table->string('body'); + $table->foreignId('question_id')->constrained(); + }); + + $this->assertTrue(Schema::hasForeignKeyForColumn('question_id', 'answers', 'questions')); + $this->assertFalse(Schema::hasForeignKeyForColumn('body', 'answers', 'questions')); + } } From 631137702f3bf8459ff8f6d0377ac74d8aefd5d7 Mon Sep 17 00:00:00 2001 From: taylorotwell Date: Wed, 3 Jan 2024 14:12:39 +0000 Subject: [PATCH 12/32] Update facade docblocks --- src/Illuminate/Support/Facades/Schema.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Support/Facades/Schema.php b/src/Illuminate/Support/Facades/Schema.php index 8d4d9b0c0dc8..8aa0eb900a55 100755 --- a/src/Illuminate/Support/Facades/Schema.php +++ b/src/Illuminate/Support/Facades/Schema.php @@ -39,6 +39,10 @@ * @method static \Illuminate\Database\Connection getConnection() * @method static \Illuminate\Database\Schema\Builder setConnection(\Illuminate\Database\Connection $connection) * @method static void blueprintResolver(\Closure $resolver) + * @method static void macro(string $name, object|callable $macro) + * @method static void mixin(object $mixin, bool $replace = true) + * @method static bool hasMacro(string $name) + * @method static void flushMacros() * * @see \Illuminate\Database\Schema\Builder */ From f434c2623472bcd2df6e3fc3194965e848d1dfe9 Mon Sep 17 00:00:00 2001 From: Mahmood Dehghani Date: Thu, 4 Jan 2024 02:10:04 +0330 Subject: [PATCH 13/32] Remove unused code from tests (#49566) --- tests/Database/DatabaseEloquentModelTest.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tests/Database/DatabaseEloquentModelTest.php b/tests/Database/DatabaseEloquentModelTest.php index 959f03e2e12b..395629b4f9b1 100755 --- a/tests/Database/DatabaseEloquentModelTest.php +++ b/tests/Database/DatabaseEloquentModelTest.php @@ -3085,22 +3085,6 @@ public function newQuery() } } -class EloquentModelHydrateRawStub extends Model -{ - public static function hydrate(array $items, $connection = null) - { - return 'hydrated'; - } - - public function getConnection() - { - $mock = m::mock(Connection::class); - $mock->shouldReceive('select')->once()->with('SELECT ?', ['foo'])->andReturn([]); - - return $mock; - } -} - class EloquentModelWithStub extends Model { public function newQuery() From 551569ee1064028d32e5ff05f9bc7a4f31f503b4 Mon Sep 17 00:00:00 2001 From: Grldk <33746490+Grldk@users.noreply.github.com> Date: Wed, 3 Jan 2024 23:40:30 +0100 Subject: [PATCH 14/32] Update Builder.php (#49563) `$columns` can be `null` (before any columns are selected --- src/Illuminate/Database/Query/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 3aa2b542e10e..9fdc9bd7ded3 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -82,7 +82,7 @@ class Builder implements BuilderContract /** * The columns that should be returned. * - * @var array + * @var array|null */ public $columns; From bd3161db1c7d52a3f5521240f0609703ca0ffc1e Mon Sep 17 00:00:00 2001 From: Dwight Watson Date: Thu, 4 Jan 2024 09:42:32 +1100 Subject: [PATCH 15/32] [10.x] Add assertViewEmpty to TestView (#49558) * Add assertEmpty to TestView * Update TestView.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Testing/TestView.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Illuminate/Testing/TestView.php b/src/Illuminate/Testing/TestView.php index 137b41e6a992..ad64fb5b73a7 100644 --- a/src/Illuminate/Testing/TestView.php +++ b/src/Illuminate/Testing/TestView.php @@ -106,6 +106,16 @@ public function assertViewMissing($key) return $this; } + /** + * Assert that the view's rendered content is empty. + */ + public function assertViewEmpty() + { + PHPUnit::assertEmpty($this->rendered); + + return true; + } + /** * Assert that the given string is contained within the view. * From 194b7a7c8ea35d9c87a4974def7e976c8673e296 Mon Sep 17 00:00:00 2001 From: Sabin Chacko <31690816+sabinchacko03@users.noreply.github.com> Date: Thu, 4 Jan 2024 02:51:06 +0400 Subject: [PATCH 16/32] [10.x] Update tailwind.blade.php for dark mode (#49515) * Update tailwind.blade.php for dark mode * Update simple-tailwind.blade.php adding dark mode classes. --- .../resources/views/simple-tailwind.blade.php | 8 +++---- .../resources/views/tailwind.blade.php | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php b/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php index 6872cca360d5..ea02400f468c 100644 --- a/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php +++ b/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php @@ -2,22 +2,22 @@