diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index ac2642c67cd3..87ec3fe1955c 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -845,7 +845,9 @@ public static function where($array, callable $callback) */ public static function whereNotNull($array) { - return static::where($array, fn ($value) => ! is_null($value)); + return static::where($array, function ($value) { + return ! is_null($value); + }); } /** diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 76fe09f1b931..91b92bd4734d 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -85,9 +85,11 @@ public function avg($callback = null) { $callback = $this->valueRetriever($callback); - $items = $this - ->map(fn ($value) => $callback($value)) - ->filter(fn ($value) => ! is_null($value)); + $items = $this->map(function ($value) use ($callback) { + return $callback($value); + })->filter(function ($value) { + return ! is_null($value); + }); if ($count = $items->count()) { return $items->sum() / $count; @@ -353,10 +355,14 @@ public function duplicatesStrict($callback = null) protected function duplicateComparator($strict) { if ($strict) { - return fn ($a, $b) => $a === $b; + return function ($a, $b) { + return $a === $b; + }; } - return fn ($a, $b) => $a == $b; + return function ($a, $b) { + return $a == $b; + }; } /** @@ -1159,7 +1165,9 @@ public function sliding($size = 2, $step = 1) { $chunks = floor(($this->count() - $size) / $step) + 1; - return static::times($chunks, fn ($number) => $this->slice(($number - 1) * $step, $size)); + return static::times($chunks, function ($number) use ($size, $step) { + return $this->slice(($number - 1) * $step, $size); + }); } /** @@ -1640,9 +1648,13 @@ public function values() */ public function zip($items) { - $arrayableItems = array_map(fn ($items) => $this->getArrayableItems($items), func_get_args()); + $arrayableItems = array_map(function ($items) { + return $this->getArrayableItems($items); + }, func_get_args()); - $params = array_merge([fn () => new static(func_get_args()), $this->items], $arrayableItems); + $params = array_merge([function () { + return new static(func_get_args()); + }, $this->items], $arrayableItems); return new static(array_map(...$params)); } diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index 8aa7cf1a302d..c22da245d31c 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -433,7 +433,9 @@ public function except($keys) public function filter(callable $callback = null) { if (is_null($callback)) { - $callback = fn ($value) => (bool) $value; + $callback = function ($value) { + return (bool) $value; + }; } return new static(function () use ($callback) { @@ -1519,7 +1521,9 @@ public function takeWhile($value) /** @var callable(TValue, TKey): bool $callback */ $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - return $this->takeUntil(fn ($item, $key) => ! $callback($item, $key)); + return $this->takeUntil(function ($item, $key) use ($callback) { + return ! $callback($item, $key); + }); } /** diff --git a/src/Illuminate/Console/Scheduling/CacheEventMutex.php b/src/Illuminate/Console/Scheduling/CacheEventMutex.php index 76036835310c..836c23cef3b4 100644 --- a/src/Illuminate/Console/Scheduling/CacheEventMutex.php +++ b/src/Illuminate/Console/Scheduling/CacheEventMutex.php @@ -62,7 +62,7 @@ public function exists(Event $event) if ($this->cache->store($this->store)->getStore() instanceof LockProvider) { return ! $this->cache->store($this->store)->getStore() ->lock($event->mutexName(), $event->expiresAt * 60) - ->get(fn () => true); + ->get(function () { return true; }); } return $this->cache->store($this->store)->has($event->mutexName()); diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 9b49633028d9..dc505ac6b954 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -66,11 +66,15 @@ public function handle() $this->components->twoColumnDetail('Migration name', 'Batch / Status'); $migrations - ->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) { - return str($migration[1])->contains('Pending'); - })) + ->when($this->option('pending'), function ($collection) { + return $collection->filter(function ($migration) { + return str($migration[1])->contains('Pending'); + }); + }) ->each( - function ($migration) { return $this->components->twoColumnDetail($migration[0], $migration[1]); } + function ($migration) { + return $this->components->twoColumnDetail($migration[0], $migration[1]); + } ); $this->newLine(); diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 6b61a14acc55..9497ac29ea50 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -1100,7 +1100,9 @@ public function push() */ public function pushQuietly() { - return static::withoutEvents(fn () => $this->push()); + return static::withoutEvents(function () { + return $this->push(); + }); } /** diff --git a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php b/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php index a514443562fd..a1e06896fc69 100644 --- a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php @@ -375,9 +375,13 @@ public function createMany(/*iterable */$records) * @param iterable $records * @return \Illuminate\Database\Eloquent\Collection */ - public function createManyQuietly(iterable $records) + public function createManyQuietly(/*iterable */$records) { - return Model::withoutEvents(fn () => $this->createMany($records)); + $records = backport_type_check('iterable', $records); + + return Model::withoutEvents(function () use ($records) { + return $this->createMany($records); + }); } /** diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index c1d56e27addb..e12652a036ed 100644 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -528,7 +528,10 @@ protected function resolvePath(/*string */$path) return new $class; } - $migration = static::$requiredPathCache[$path] ??= $this->files->getRequire($path); + if (! isset(static::$requiredPathCache[$path])) { + static::$requiredPathCache[$path] = $this->files->getRequire($path); + } + $migration = static::$requiredPathCache[$path]; if (is_object($migration)) { return clone $migration; diff --git a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php index 325a5dd6a8e9..35fe746e3d22 100644 --- a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php @@ -83,11 +83,11 @@ public function whereFullText(Builder $query, $where) */ protected function compileIndexHint(Builder $query, $indexHint) { - return match ($indexHint->type) { - 'hint' => "use index ({$indexHint->index})", - 'force' => "force index ({$indexHint->index})", - default => "ignore index ({$indexHint->index})", - }; + switch ($indexHint->type) { + case 'hint': return "use index ({$indexHint->index})"; + case 'force': return "force index ({$indexHint->index})"; + default: return "ignore index ({$indexHint->index})"; + } } /** diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index cdc8e0e41562..46ad527e7fbb 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -320,11 +320,15 @@ protected function shouldntReport(/*Throwable */$e) */ public function stopIgnoring(string $exception) { + $exception = backport_type_check('string', $exception); + $this->dontReport = collect($this->dontReport) - ->reject(fn ($ignored) => $ignored === $exception)->values()->all(); + ->reject(function ($ignored) use ($exception) { return $ignored === $exception; }) + ->values()->all(); $this->internalDontReport = collect($this->internalDontReport) - ->reject(fn ($ignored) => $ignored === $exception)->values()->all(); + ->reject(function ($ignored) use ($exception) { return $ignored === $exception; }) + ->values()->all(); return $this; } diff --git a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php index 45ab6a6c3f7f..5483a312c749 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php @@ -90,11 +90,11 @@ protected function truncateTablesForConnection(ConnectionInterface $connection, collect(static::$allTables[$name]) ->when( property_exists($this, 'tablesToTruncate'), - fn ($tables) => $tables->intersect($this->tablesToTruncate), - fn ($tables) => $tables->diff($this->exceptTables($name)) + function ($tables) { return $tables->intersect($this->tablesToTruncate); }, + function ($tables) { return $tables->diff($this->exceptTables($name)); } ) - ->filter(fn ($table) => $connection->table($table)->exists()) - ->each(fn ($table) => $connection->table($table)->truncate()); + ->filter(function ($table) use ($connection) { return $connection->table($table)->exists(); }) + ->each(function ($table) use ($connection) { return $connection->table($table)->truncate(); }); $connection->setEventDispatcher($dispatcher); } diff --git a/src/Illuminate/Mail/MailManager.php b/src/Illuminate/Mail/MailManager.php index 6e286ca22d36..c862a901a9b8 100644 --- a/src/Illuminate/Mail/MailManager.php +++ b/src/Illuminate/Mail/MailManager.php @@ -283,7 +283,7 @@ protected function createSesV2Transport(array $config) return new SesV2Transport( new SesV2Client($this->addSesCredentials($config)), - $config['options'] ?? [] + isset($config['options']) ? $config['options'] : [] ); } diff --git a/src/Illuminate/Mail/Transport/SesTransport.php b/src/Illuminate/Mail/Transport/SesTransport.php index cd7192a23c8b..bb4e7a000a93 100644 --- a/src/Illuminate/Mail/Transport/SesTransport.php +++ b/src/Illuminate/Mail/Transport/SesTransport.php @@ -151,7 +151,8 @@ public function setOptions(array $options) * * @return string */ - public function __toString(): string + #[\ReturnTypeWillChange] + public function __toString()/*: string*/ { return 'ses'; } diff --git a/src/Illuminate/Mail/Transport/SesV2Transport.php b/src/Illuminate/Mail/Transport/SesV2Transport.php index 4157570e5bd0..ccc761f62c33 100644 --- a/src/Illuminate/Mail/Transport/SesV2Transport.php +++ b/src/Illuminate/Mail/Transport/SesV2Transport.php @@ -44,7 +44,7 @@ public function __construct(SesV2Client $ses, $options = []) /** * {@inheritDoc} */ - protected function doSend(SentMessage $message): void + protected function doSend(SentMessage $message)/*: void*/ { $options = $this->options; @@ -77,7 +77,9 @@ protected function doSend(SentMessage $message): void ) ); } catch (AwsException $e) { - $reason = $e->getAwsErrorMessage() ?? $e->getMessage(); + $awsReason = $e->getAwsErrorMessage(); + + $reason = isset($awsReason) ? $awsReason : $e->getMessage(); throw new Exception( sprintf('Request to AWS SES V2 API failed. Reason: %s.', $reason), @@ -128,7 +130,8 @@ public function setOptions(array $options) * * @return string */ - public function __toString(): string + #[\ReturnTypeWillChange] + public function __toString()/*: string*/ { return 'ses-v2'; } diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 2338faa823c1..3124ef2f9de4 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -738,23 +738,27 @@ public static function pluralStudly($value, $count = 2) public static function password($length = 32, $letters = true, $numbers = true, $symbols = true, $spaces = false) { return (new Collection) - ->when($letters, fn ($c) => $c->merge([ + ->when($letters, function ($c) { return $c->merge([ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - ])) - ->when($numbers, fn ($c) => $c->merge([ + ]); }) + ->when($numbers, function ($c) { return $c->merge([ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - ])) - ->when($symbols, fn ($c) => $c->merge([ + ]); }) + ->when($symbols, function ($c) { return $c->merge([ '~', '!', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '.', ',', '<', '>', '?', '/', '\\', '{', '}', '[', ']', '|', ':', ';', - ])) - ->when($spaces, fn ($c) => $c->merge([' '])) - ->pipe(fn ($c) => Collection::times($length, fn () => $c[random_int(0, $c->count() - 1)])) + ]); }) + ->when($spaces, function ($c) { return $c->merge([' ']); }) + ->pipe(function ($c) use ($length) { + return Collection::times($length, function () use ($c) { + return $c[random_int(0, $c->count() - 1)]; + }); + }) ->implode(''); } diff --git a/src/Illuminate/Support/Testing/Fakes/BusFake.php b/src/Illuminate/Support/Testing/Fakes/BusFake.php index a5ee1e0afce0..eca30f6f4454 100644 --- a/src/Illuminate/Support/Testing/Fakes/BusFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BusFake.php @@ -136,7 +136,7 @@ public function assertDispatchedTimes($command, $times = 1) $callback = null; if ($command instanceof Closure) { - [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + list($command, $callback) = [$this->firstClosureParameterType($command), $command]; } $count = $this->dispatched($command, $callback)->count() + @@ -215,7 +215,7 @@ public function assertDispatchedSyncTimes($command, $times = 1) $callback = null; if ($command instanceof Closure) { - [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + list($command, $callback) = [$this->firstClosureParameterType($command), $command]; } $count = $this->dispatchedSync($command, $callback)->count(); @@ -280,7 +280,7 @@ public function assertDispatchedAfterResponseTimes($command, $times = 1) $callback = null; if ($command instanceof Closure) { - [$command, $callback] = [$this->firstClosureParameterType($command), $command]; + list($command, $callback) = [$this->firstClosureParameterType($command), $command]; } $count = $this->dispatchedAfterResponse($command, $callback)->count(); diff --git a/src/Illuminate/Translation/MessageSelector.php b/src/Illuminate/Translation/MessageSelector.php index 263716552347..cecc095f9d87 100644 --- a/src/Illuminate/Translation/MessageSelector.php +++ b/src/Illuminate/Translation/MessageSelector.php @@ -90,7 +90,9 @@ private function extractFromString($part, $number) private function stripConditions($segments) { return collect($segments) - ->map(fn ($part) => preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part)) + ->map(function ($part) { + return preg_replace('/^[\{\[]([^\[\]\{\}]*)[\}\]]/', '', $part); + }) ->all(); } diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index 71ab1e821e23..16371395f43d 100644 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -526,7 +526,7 @@ public function testMacroable()/*: void*/ } /** @test */ - public function testUseConfigPath(): void + public function testUseConfigPath()/*: void*/ { $app = new Application; $app->useConfigPath(__DIR__.'/fixtures/config'); diff --git a/tests/Foundation/FoundationInteractsWithDatabaseTest.php b/tests/Foundation/FoundationInteractsWithDatabaseTest.php index 7f839e31969a..8253af032953 100644 --- a/tests/Foundation/FoundationInteractsWithDatabaseTest.php +++ b/tests/Foundation/FoundationInteractsWithDatabaseTest.php @@ -16,6 +16,7 @@ class FoundationInteractsWithDatabaseTest_testExpectsDatabaseQueryCount_class_1 extends TestingTestCase { + use \PHPUnit\Framework\PhpUnit8Assert; use CreatesApplication; public function testExpectsDatabaseQueryCount() @@ -26,6 +27,7 @@ public function testExpectsDatabaseQueryCount() class FoundationInteractsWithDatabaseTest_testExpectsDatabaseQueryCount_class_2 extends TestingTestCase { + use \PHPUnit\Framework\PhpUnit8Assert; use CreatesApplication; public function testExpectsDatabaseQueryCount() @@ -36,6 +38,7 @@ public function testExpectsDatabaseQueryCount() class FoundationInteractsWithDatabaseTest_testExpectsDatabaseQueryCount_class_3 extends TestingTestCase { + use \PHPUnit\Framework\PhpUnit8Assert; use CreatesApplication; public function testExpectsDatabaseQueryCount() diff --git a/tests/Integration/Events/EventFakeTest.php b/tests/Integration/Events/EventFakeTest.php index 2b225d7c030e..fc56e1756d7a 100644 --- a/tests/Integration/Events/EventFakeTest.php +++ b/tests/Integration/Events/EventFakeTest.php @@ -176,7 +176,7 @@ public function testAssertListening() public function testMissingMethodsAreForwarded() { - Event::macro('foo', fn () => 'bar'); + Event::macro('foo', function () { return 'bar'; }); $this->assertEquals('bar', Event::fake()->foo()); } diff --git a/tests/Mail/MailMailerTest.php b/tests/Mail/MailMailerTest.php index 389adbacd86e..73e9d482f57f 100644 --- a/tests/Mail/MailMailerTest.php +++ b/tests/Mail/MailMailerTest.php @@ -33,7 +33,7 @@ public function testMailerSendSendsMessageWithProperViewContent() $message = m::mock(Swift_Mime_SimpleMessage::class); $mailer->expects($this->once())->method('createMessage')->willReturn($message); $view = m::mock(stdClass::class); - $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view); + $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'mailer' => 'smtp', 'message' => $message])->andReturn($view); $view->shouldReceive('render')->once()->andReturn('rendered.view'); $message->shouldReceive('setBody')->once()->with('rendered.view', 'text/html'); $message->shouldReceive('setFrom')->never(); @@ -121,8 +121,8 @@ public function testMailerSendSendsMessageWithProperPlainViewContent() $message = m::mock(Swift_Mime_SimpleMessage::class); $mailer->expects($this->once())->method('createMessage')->willReturn($message); $view = m::mock(stdClass::class); - $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view); - $mailer->getViewFactory()->shouldReceive('make')->once()->with('bar', ['data', 'message' => $message])->andReturn($view); + $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'mailer' => 'smtp', 'message' => $message])->andReturn($view); + $mailer->getViewFactory()->shouldReceive('make')->once()->with('bar', ['data', 'mailer' => 'smtp', 'message' => $message])->andReturn($view); $view->shouldReceive('render')->twice()->andReturn('rendered.view'); $message->shouldReceive('setBody')->once()->with('rendered.view', 'text/html'); $message->shouldReceive('addPart')->once()->with('rendered.view', 'text/plain'); @@ -143,8 +143,8 @@ public function testMailerSendSendsMessageWithProperPlainViewContentWhenExplicit $message = m::mock(Swift_Mime_SimpleMessage::class); $mailer->expects($this->once())->method('createMessage')->willReturn($message); $view = m::mock(stdClass::class); - $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'message' => $message])->andReturn($view); - $mailer->getViewFactory()->shouldReceive('make')->once()->with('bar', ['data', 'message' => $message])->andReturn($view); + $mailer->getViewFactory()->shouldReceive('make')->once()->with('foo', ['data', 'mailer' => 'smtp', 'message' => $message])->andReturn($view); + $mailer->getViewFactory()->shouldReceive('make')->once()->with('bar', ['data', 'mailer' => 'smtp', 'message' => $message])->andReturn($view); $view->shouldReceive('render')->twice()->andReturn('rendered.view'); $message->shouldReceive('setBody')->once()->with('rendered.view', 'text/html'); $message->shouldReceive('addPart')->once()->with('rendered.view', 'text/plain'); diff --git a/tests/Mail/MailSesV2TransportTest.php b/tests/Mail/MailSesV2TransportTest.php index 692ab537917a..93c8eba03f0c 100755 --- a/tests/Mail/MailSesV2TransportTest.php +++ b/tests/Mail/MailSesV2TransportTest.php @@ -15,7 +15,7 @@ class MailSesV2TransportTest extends TestCase { - protected function tearDown(): void + protected function tearDown()/*: void*/ { m::close(); @@ -24,6 +24,8 @@ protected function tearDown(): void public function testGetTransport() { + $this->markTestSkipped('Needs symfony/mailer 6'); + $container = new Container; $container->singleton('config', function () { @@ -50,6 +52,8 @@ public function testGetTransport() public function testSend() { + $this->markTestSkipped('Needs symfony/mailer 6'); + $message = new Email(); $message->subject('Foo subject'); $message->text('Bar body'); @@ -78,6 +82,8 @@ public function testSend() public function testSesV2LocalConfiguration() { + $this->markTestSkipped('Needs symfony/mailer 6'); + $container = new Container; $container->singleton('config', function () { diff --git a/tests/Support/SupportMailTest.php b/tests/Support/SupportMailTest.php index 20cf09c7783d..2312de2aed60 100644 --- a/tests/Support/SupportMailTest.php +++ b/tests/Support/SupportMailTest.php @@ -9,20 +9,26 @@ class SupportMailTest extends TestCase { public function testItRegisterAndCallMacros() { - Mail::macro('test', fn (string $str) => $str === 'foo' - ? 'it works!' - : 'it failed.', - ); + Mail::macro('test', function (/*string */$str) { + $str = backport_type_check('string', $str); + + return $str === 'foo' + ? 'it works!' + : 'it failed.'; + }); $this->assertEquals('it works!', Mail::test('foo')); } public function testItRegisterAndCallMacrosWhenFaked() { - Mail::macro('test', fn (string $str) => $str === 'foo' - ? 'it works!' - : 'it failed.', - ); + Mail::macro('test', function (/*string */$str) { + $str = backport_type_check('string', $str); + + return $str === 'foo' + ? 'it works!' + : 'it failed.'; + }); Mail::fake();