diff --git a/tests/Cms/Api/ApiTest.php b/tests/Cms/Api/ApiTest.php index 75263425d2..16ecfa019f 100644 --- a/tests/Cms/Api/ApiTest.php +++ b/tests/Cms/Api/ApiTest.php @@ -52,16 +52,12 @@ public function setUp(): void 'options' => [ 'api' => [ 'allowImpersonation' => true, - 'authentication' => function () { - return true; - }, - 'routes' => [ + 'authentication' => fn () => true, + 'routes' => [ [ 'pattern' => 'foo', 'method' => 'GET', - 'action' => function () { - return 'something'; - } + 'action' => fn () => 'something' ] ] ], @@ -664,18 +660,14 @@ public function testSectionApi() $app = $this->app->clone([ 'sections' => [ 'test' => [ - 'api' => function () { - return [ - [ - 'pattern' => '/message', - 'action' => function () { - return [ - 'message' => 'Test' - ]; - } + 'api' => fn () => [ + [ + 'pattern' => '/message', + 'action' => fn () => [ + 'message' => 'Test' ] - ]; - } + ] + ] ] ], 'blueprints' => [ diff --git a/tests/Cms/Api/routes/AccountRoutesTest.php b/tests/Cms/Api/routes/AccountRoutesTest.php index 14d2a720b9..bb659087b2 100644 --- a/tests/Cms/Api/routes/AccountRoutesTest.php +++ b/tests/Cms/Api/routes/AccountRoutesTest.php @@ -218,22 +218,16 @@ public function testFields() ], 'fields' => [ 'test' => [ - 'api' => function () { - return [ - [ - 'pattern' => '/', - 'action' => function () { - return 'Test home route'; - } - ], - [ - 'pattern' => 'nested', - 'action' => function () { - return 'Test nested route'; - } - ], - ]; - } + 'api' => fn () => [ + [ + 'pattern' => '/', + 'action' => fn () => 'Test home route' + ], + [ + 'pattern' => 'nested', + 'action' => fn () => 'Test nested route' + ], + ] ] ] ]); @@ -371,11 +365,9 @@ public function testSections() ], 'sections' => [ 'test' => [ - 'toArray' => function () { - return [ - 'foo' => 'bar' - ]; - } + 'toArray' => fn () => [ + 'foo' => 'bar' + ] ] ] ]); diff --git a/tests/Cms/Api/routes/UsersRoutesTest.php b/tests/Cms/Api/routes/UsersRoutesTest.php index e16469ae10..2fde03dade 100644 --- a/tests/Cms/Api/routes/UsersRoutesTest.php +++ b/tests/Cms/Api/routes/UsersRoutesTest.php @@ -237,22 +237,16 @@ public function testFields() ], 'fields' => [ 'test' => [ - 'api' => function () { - return [ - [ - 'pattern' => '/', - 'action' => function () { - return 'Test home route'; - } - ], - [ - 'pattern' => 'nested', - 'action' => function () { - return 'Test nested route'; - } - ], - ]; - } + 'api' => fn () => [ + [ + 'pattern' => '/', + 'action' => fn () => 'Test home route' + ], + [ + 'pattern' => 'nested', + 'action' => fn () => 'Test nested route' + ], + ] ] ] ]); @@ -431,11 +425,9 @@ public function testSections() ], 'sections' => [ 'test' => [ - 'toArray' => function () { - return [ - 'foo' => 'bar' - ]; - } + 'toArray' => fn () => [ + 'foo' => 'bar' + ] ] ] ]); diff --git a/tests/Cms/App/AppComponentsTest.php b/tests/Cms/App/AppComponentsTest.php index 53c9a2a8c5..97cb2bab4b 100644 --- a/tests/Cms/App/AppComponentsTest.php +++ b/tests/Cms/App/AppComponentsTest.php @@ -44,9 +44,7 @@ public function testCssPlugin() { $this->kirby->clone([ 'components' => [ - 'css' => function ($kirby, $url, $options) { - return '/test.css'; - } + 'css' => fn ($kirby, $url, $options) => '/test.css' ] ]); @@ -58,9 +56,7 @@ public function testJsPlugin() { $this->kirby->clone([ 'components' => [ - 'js' => function ($kirby, $url, $options) { - return '/test.js'; - } + 'js' => fn ($kirby, $url, $options) => '/test.js' ] ]); @@ -361,9 +357,7 @@ public function testUrlPlugin() { $this->kirby->clone([ 'components' => [ - 'url' => function ($kirby, $path, $options) { - return 'test'; - } + 'url' => fn ($kirby, $path, $options) => 'test' ] ]); diff --git a/tests/Cms/App/AppPluginsTest.php b/tests/Cms/App/AppPluginsTest.php index 1fff1302f6..99c90c05ad 100644 --- a/tests/Cms/App/AppPluginsTest.php +++ b/tests/Cms/App/AppPluginsTest.php @@ -67,14 +67,10 @@ public function testApi() 'routes' => [ [ 'pattern' => 'awesome', - 'action' => function () { - return 'nice'; - } + 'action' => fn () => 'nice' ] ], - 'authentication' => function () { - return true; - } + 'authentication' => fn () => true ] ]); @@ -89,9 +85,7 @@ public function testApiRoutePlugins() 'routes' => [ [ 'pattern' => 'a', - 'action' => function () { - return 'a'; - } + 'action' => fn () => 'a' ] ] ] @@ -102,9 +96,7 @@ public function testApiRoutePlugins() 'routes' => [ [ 'pattern' => 'b', - 'action' => function () { - return 'b'; - } + 'action' => fn () => 'b' ] ] ] @@ -115,9 +107,7 @@ public function testApiRoutePlugins() 'routes' => [ [ 'pattern' => 'c', - 'action' => function () { - return 'c'; - } + 'action' => fn () => 'c' ] ] ] @@ -128,9 +118,7 @@ public function testApiRoutePlugins() 'index' => '/dev/null' ], 'api' => [ - 'authentication' => function () { - return true; - } + 'authentication' => fn () => true ], ]); @@ -145,31 +133,23 @@ public function testApiRouteCallbackPlugins() { App::plugin('test/a', [ 'api' => [ - 'routes' => function ($kirby) { - return [ - [ - 'pattern' => 'a', - 'action' => function () use ($kirby) { - return $kirby->root('index'); - } - ] - ]; - } + 'routes' => fn ($kirby) => [ + [ + 'pattern' => 'a', + 'action' => fn () => $kirby->root('index') + ] + ] ] ]); App::plugin('test/b', [ 'api' => [ - 'routes' => function ($kirby) { - return [ - [ - 'pattern' => 'b', - 'action' => function () { - return 'b'; - } - ] - ]; - } + 'routes' => fn ($kirby) => [ + [ + 'pattern' => 'b', + 'action' => fn () => 'b' + ] + ] ] ]); @@ -178,9 +158,7 @@ public function testApiRouteCallbackPlugins() 'routes' => [ [ 'pattern' => 'c', - 'action' => function () { - return 'c'; - } + 'action' => fn () => 'c' ] ] ] @@ -191,9 +169,7 @@ public function testApiRouteCallbackPlugins() 'index' => '/dev/null' ], 'api' => [ - 'authentication' => function () { - return true; - } + 'authentication' => fn () => true ], ]); @@ -211,16 +187,12 @@ public function testApiRouteCallbackPluginWithOptionAccess() 'test' => 'Test' ], 'api' => [ - 'routes' => function ($kirby) { - return [ - [ - 'pattern' => 'test', - 'action' => function () use ($kirby) { - return $kirby->option('your.plugin.test'); - } - ] - ]; - } + 'routes' => fn ($kirby) => [ + [ + 'pattern' => 'test', + 'action' => fn () => $kirby->option('your.plugin.test') + ] + ] ] ]); @@ -342,9 +314,7 @@ public function testCollectionFilters() ], 'collectionFilters' => [ '**' => $filter = [ - 'validator' => function ($value, $test) { - return $value === 'foo'; - } + 'validator' => fn ($value, $test) => $value === 'foo' ] ] ]); @@ -380,9 +350,7 @@ public function testController() 'index' => '/dev/null' ], 'controllers' => [ - 'test' => function () { - return ['foo' => 'bar']; - } + 'test' => fn () => ['foo' => 'bar'] ] ]); @@ -396,9 +364,7 @@ public function testFieldMethod() 'index' => '/dev/null' ], 'fieldMethods' => [ - 'test' => function () { - return 'test'; - } + 'test' => fn () => 'test' ] ]); @@ -440,14 +406,10 @@ public function testKirbyTag() ], 'tags' => [ 'test' => [ - 'html' => function () { - return 'test'; - } + 'html' => fn () => 'test' ], 'FoO' => [ - 'html' => function () { - return 'test'; - } + 'html' => fn () => 'test' ] ] ]); @@ -466,9 +428,7 @@ public function testPageMethod() 'index' => '/dev/null' ], 'pageMethods' => [ - 'test' => function () { - return 'test'; - } + 'test' => fn () => 'test' ] ]); @@ -486,9 +446,7 @@ public function testPagesMethod() 'index' => '/dev/null' ], 'pagesMethods' => [ - 'test' => function () { - return 'test'; - } + 'test' => fn () => 'test' ] ]); @@ -731,9 +689,7 @@ public function testRoutes() 'routes' => [ [ 'pattern' => 'test', - 'action' => function () { - return 'test'; - } + 'action' => fn () => 'test' ] ] ]); @@ -747,16 +703,12 @@ public function testRoutesCallback() 'roots' => [ 'index' => '/dev/null' ], - 'routes' => function () { - return [ - [ - 'pattern' => 'test', - 'action' => function () { - return 'test'; - } - ] - ]; - } + 'routes' => fn () => [ + [ + 'pattern' => 'test', + 'action' => fn () => 'test' + ] + ] ]); $this->assertSame('test', $kirby->call('test')); @@ -850,9 +802,7 @@ public function testUserMethod() 'index' => '/dev/null' ], 'userMethods' => [ - 'test' => function () { - return 'test'; - } + 'test' => fn () => 'test' ] ]); @@ -892,9 +842,7 @@ public function testUsersMethod() 'index' => '/dev/null' ], 'usersMethods' => [ - 'test' => function () { - return 'test'; - } + 'test' => fn () => 'test' ] ]); @@ -1031,9 +979,7 @@ public function testAreas() 'index' => '/dev/null' ], 'areas' => [ - 'todos' => function () { - return []; - } + 'todos' => fn () => [] ] ]); diff --git a/tests/Cms/App/AppTest.php b/tests/Cms/App/AppTest.php index a25b0218d7..52f3ef18a4 100644 --- a/tests/Cms/App/AppTest.php +++ b/tests/Cms/App/AppTest.php @@ -192,9 +192,7 @@ public function testCollection() ] ], 'collections' => [ - 'test' => function ($pages) { - return $pages; - } + 'test' => fn ($pages) => $pages ] ]); @@ -287,9 +285,7 @@ public function testContentToken() // with callback $app = new App([ 'options' => [ - 'content.salt' => function ($model) { - return 'salt ' . $model; - } + 'content.salt' => fn ($model) => 'salt ' . $model ] ]); $this->assertSame(hash_hmac('sha1', 'test', 'salt lake city'), $app->contentToken('lake city', 'test')); @@ -719,16 +715,14 @@ public function testOptionsOnReady() ] ], 'options' => [ - 'ready' => $ready = function ($kirby) { - return [ - 'test' => $kirby->root('index'), - 'another.test' => 'foo', - 'debug' => true, - 'home' => $kirby->site()->content()->home()->value(), - 'error' => $kirby->site()->content()->error()->value(), - 'slugs' => 'de' - ]; - }, + 'ready' => $ready = fn ($kirby) => [ + 'test' => $kirby->root('index'), + 'another.test' => 'foo', + 'debug' => true, + 'home' => $kirby->site()->content()->home()->value(), + 'error' => $kirby->site()->content()->error()->value(), + 'slugs' => 'de' + ], 'whoops' => true ] ]); @@ -1332,9 +1326,8 @@ public function testControllerCallback() 'index' => '/dev/null' ], 'controllers' => [ - 'test' => function () { - return ['foo' => 'bar']; - } + 'test' => fn () => ['foo' => 'bar'] + ] ]); diff --git a/tests/Cms/Blocks/BlocksMethodsTest.php b/tests/Cms/Blocks/BlocksMethodsTest.php index da48117798..e1e949da61 100644 --- a/tests/Cms/Blocks/BlocksMethodsTest.php +++ b/tests/Cms/Blocks/BlocksMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'blocksMethods' => [ - 'test' => function () { - return 'blocks method'; - } + 'test' => fn () => 'blocks method' ] ]); } diff --git a/tests/Cms/Blueprints/BlueprintTest.php b/tests/Cms/Blueprints/BlueprintTest.php index 5c0f9509ad..bb392a67fa 100644 --- a/tests/Cms/Blueprints/BlueprintTest.php +++ b/tests/Cms/Blueprints/BlueprintTest.php @@ -649,9 +649,7 @@ public function testFactoryWithCallbackArray() $this->app = $this->app->clone([ 'blueprints' => [ - 'pages/test' => function () { - return ['title' => 'Test']; - } + 'pages/test' => fn () => ['title' => 'Test'] ] ]); @@ -675,9 +673,7 @@ public function testFactoryWithCallbackString() 'blueprints' => static::TMP, ], 'blueprints' => [ - 'pages/test' => function () { - return static::TMP . '/custom/test.yml'; - } + 'pages/test' => fn () => static::TMP . '/custom/test.yml' ] ]); diff --git a/tests/Cms/Collections/CollectionTest.php b/tests/Cms/Collections/CollectionTest.php index 1a2c3abc34..a95672c565 100644 --- a/tests/Cms/Collections/CollectionTest.php +++ b/tests/Cms/Collections/CollectionTest.php @@ -47,9 +47,7 @@ public function testCollectionMethods() { $kirby = $this->kirby([ 'collectionMethods' => [ - 'test' => function () { - return 'collection test'; - } + 'test' => fn () => 'collection test' ], 'roots' => [ 'index' => '/dev/null' @@ -502,9 +500,7 @@ public function testToArrayWithCallback() new MockObject(['id' => 'c']) ]); - $array = $collection->toArray(function ($object) { - return $object->id(); - }); + $array = $collection->toArray(fn ($object) => $object->id()); $this->assertSame($array, [ 'a' => 'a', diff --git a/tests/Cms/KirbyTextTest.php b/tests/Cms/KirbyTextTest.php index f80a38b77c..c25b585949 100644 --- a/tests/Cms/KirbyTextTest.php +++ b/tests/Cms/KirbyTextTest.php @@ -13,9 +13,7 @@ public function testBeforeHook() 'index' => '/dev/null' ], 'hooks' => [ - 'kirbytext:before' => function ($text) { - return strtolower($text); - } + 'kirbytext:before' => fn ($text) => strtolower($text) ] ]); @@ -31,9 +29,7 @@ public function testAfterHook() 'index' => '/dev/null' ], 'hooks' => [ - 'kirbytext:after' => function ($text) { - return strip_tags($text); - } + 'kirbytext:after' => fn ($text) => strip_tags($text) ] ]); diff --git a/tests/Cms/Languages/LanguageRouterTest.php b/tests/Cms/Languages/LanguageRouterTest.php index 35242d76c1..0916899e8f 100644 --- a/tests/Cms/Languages/LanguageRouterTest.php +++ b/tests/Cms/Languages/LanguageRouterTest.php @@ -32,16 +32,12 @@ public function testRouteForSingleLanguage() [ 'pattern' => '(:any)', 'language' => 'en', - 'action' => function (Language $langauge, $slug) { - return 'en'; - } + 'action' => fn (Language $langauge, $slug) => 'en' ], [ 'pattern' => '(:any)', 'language' => 'de', - 'action' => function (Language $langauge, $slug) { - return 'de'; - } + 'action' => fn (Language $langauge, $slug) => 'de' ] ] ]); @@ -62,9 +58,7 @@ public function testRouteWithoutLanguageScope() 'routes' => [ [ 'pattern' => '(:any)', - 'action' => function ($slug) { - return $slug; - } + 'action' => fn ($slug) => $slug ] ] ]); @@ -81,9 +75,7 @@ public function testRouteForMultipleLanguages() [ 'pattern' => '(:any)', 'language' => 'en|de', - 'action' => function (Language $language, $slug) { - return $slug; - } + 'action' => fn (Language $language, $slug) => $slug ] ] ]); @@ -105,9 +97,7 @@ public function testRouteWildcard() [ 'pattern' => '(:any)', 'language' => '*', - 'action' => function (Language $language, $slug) { - return $slug; - } + 'action' => fn (Language $language, $slug) => $slug ] ] ]); @@ -135,9 +125,7 @@ public function testRouteWithPageScope() 'pattern' => '(:any)', 'language' => '*', 'page' => 'notes', - 'action' => function (Language $language, Page $page, $slug) { - return $slug; - } + 'action' => fn (Language $language, Page $page, $slug) => $slug ] ] ]); @@ -164,9 +152,7 @@ public function testRouteWithPageScopeAndMultiplePatterns() ], 'language' => '*', 'page' => 'notes', - 'action' => function (Language $language, Page $page, $slug) { - return $slug; - } + 'action' => fn (Language $language, Page $page, $slug) => $slug ] ] ]); @@ -191,9 +177,7 @@ public function testRouteWithPageScopeAndInvalidPage() 'pattern' => '(:any)', 'language' => '*', 'page' => 'does-not-exist', - 'action' => function (Language $language, Page $page, $slug) { - return $slug; - } + 'action' => fn (Language $language, Page $page, $slug) => $slug ] ] ]); diff --git a/tests/Cms/Layouts/LayoutColumnMethodsTest.php b/tests/Cms/Layouts/LayoutColumnMethodsTest.php index 9423bc42e4..1251ae1ce9 100644 --- a/tests/Cms/Layouts/LayoutColumnMethodsTest.php +++ b/tests/Cms/Layouts/LayoutColumnMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'layoutColumnMethods' => [ - 'test' => function () { - return 'layout column method'; - } + 'test' => fn () => 'layout column method' ] ]); } diff --git a/tests/Cms/Layouts/LayoutMethodsTest.php b/tests/Cms/Layouts/LayoutMethodsTest.php index e88215ab46..1891a3fcbb 100644 --- a/tests/Cms/Layouts/LayoutMethodsTest.php +++ b/tests/Cms/Layouts/LayoutMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'layoutMethods' => [ - 'test' => function () { - return 'layout method'; - } + 'test' => fn () => 'layout method' ] ]); } diff --git a/tests/Cms/Layouts/LayoutsMethodsTest.php b/tests/Cms/Layouts/LayoutsMethodsTest.php index 497dfa7388..edbe0293e4 100644 --- a/tests/Cms/Layouts/LayoutsMethodsTest.php +++ b/tests/Cms/Layouts/LayoutsMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'layoutsMethods' => [ - 'test' => function () { - return 'layouts method'; - } + 'test' => fn () => 'layouts method' ] ]); } diff --git a/tests/Cms/Loader/LoaderTest.php b/tests/Cms/Loader/LoaderTest.php index 9c425aed4c..5b9b9718a8 100644 --- a/tests/Cms/Loader/LoaderTest.php +++ b/tests/Cms/Loader/LoaderTest.php @@ -76,9 +76,7 @@ public function testAreaDropdownPlugin() 'areas' => [ 'site' => [ 'dropdowns' => [ - 'page' => function () { - return 'foo'; - } + 'page' => fn () => 'foo' ] ] ] diff --git a/tests/Cms/Pages/PageCacheTest.php b/tests/Cms/Pages/PageCacheTest.php index 98dee9d192..805030b154 100644 --- a/tests/Cms/Pages/PageCacheTest.php +++ b/tests/Cms/Pages/PageCacheTest.php @@ -143,9 +143,7 @@ public function testIgnoreCallback() $app = $this->app->clone([ 'options' => [ 'cache.pages' => [ - 'ignore' => function ($page) { - return $page->id() === 'default'; - } + 'ignore' => fn ($page) => $page->id() === 'default' ] ] ]); diff --git a/tests/Cms/Pages/PageMethodsTest.php b/tests/Cms/Pages/PageMethodsTest.php index 194b4b1275..1808577552 100644 --- a/tests/Cms/Pages/PageMethodsTest.php +++ b/tests/Cms/Pages/PageMethodsTest.php @@ -12,14 +12,10 @@ public function setUp(): void { $this->app = new App([ 'pageMethods' => [ - 'test' => function () { - return 'page method'; - } + 'test' => fn () => 'page method' ], 'pagesMethods' => [ - 'test' => function () { - return 'pages method'; - } + 'test' => fn () => 'pages method' ], 'site' => [ 'children' => [ diff --git a/tests/Cms/Pages/PageTest.php b/tests/Cms/Pages/PageTest.php index 8000e20b37..6a540e7901 100644 --- a/tests/Cms/Pages/PageTest.php +++ b/tests/Cms/Pages/PageTest.php @@ -707,9 +707,7 @@ public function testTokenWithSaltCallback() ], 'options' => [ 'content' => [ - 'salt' => function ($page) { - return $page->date(); - } + 'salt' => fn ($page) => $page->date() ] ] ]); @@ -956,9 +954,7 @@ public function testApiUrl() public function testPageMethods() { Page::$methods = [ - 'test' => function () { - return 'homer'; - } + 'test' => fn () => 'homer' ]; $page = new Page(['slug' => 'test']); @@ -1033,9 +1029,7 @@ public function testController() return compact('page'); }, // invalid return - 'bar' => function ($page) { - return ['page' => 'string']; - } + 'bar' => fn ($page) => ['page' => 'string'] ] ]); diff --git a/tests/Cms/Routes/RouterTest.php b/tests/Cms/Routes/RouterTest.php index 0d254c2bec..78b8140121 100644 --- a/tests/Cms/Routes/RouterTest.php +++ b/tests/Cms/Routes/RouterTest.php @@ -313,9 +313,7 @@ public function testCustomRoute($pattern, $path) 'routes' => [ [ 'pattern' => $pattern, - 'action' => function () { - return 'test'; - } + 'action' => fn () => 'test' ] ] ]); diff --git a/tests/Cms/Sections/SectionTest.php b/tests/Cms/Sections/SectionTest.php index e50ce64e68..db116fd00a 100644 --- a/tests/Cms/Sections/SectionTest.php +++ b/tests/Cms/Sections/SectionTest.php @@ -46,9 +46,7 @@ public function testApi() // return simple string Section::$types = [ 'test' => [ - 'api' => function () { - return 'Hello World'; - } + 'api' => fn () => 'Hello World' ] ]; @@ -75,12 +73,8 @@ public function testPropsDefaults() { Section::$types['test'] = [ 'props' => [ - 'example' => function ($example = 'default') { - return $example; - }, - 'buttons' => function ($buttons = ['one', 'two']) { - return $buttons; - }, + 'example' => fn ($example = 'default') => $example, + 'buttons' => fn ($buttons = ['one', 'two']) => $buttons ] ]; @@ -96,12 +90,8 @@ public function testToResponse() { Section::$types['test'] = [ 'props' => [ - 'a' => function ($a) { - return $a; - }, - 'b' => function ($b) { - return $b; - } + 'a' => fn ($a) => $a, + 'b' => fn ($b) => $b ] ]; diff --git a/tests/Cms/Sections/mixins/LayoutMixinTest.php b/tests/Cms/Sections/mixins/LayoutMixinTest.php index 9be7ccde0c..7a3785beec 100644 --- a/tests/Cms/Sections/mixins/LayoutMixinTest.php +++ b/tests/Cms/Sections/mixins/LayoutMixinTest.php @@ -21,13 +21,9 @@ public function setUp(): void Section::$types['test'] = Section::$types['pages'] = [ 'mixins' => ['layout'], - 'props' => $props = [ - 'info' => function (string|null $info = null) { - return $info; - }, - 'text' => function (string|null $text = null) { - return $text; - } + 'props' => [ + 'info' => fn (string|null $info = null) => $info, + 'text' => fn (string|null $text = null) => $text ] ]; } diff --git a/tests/Cms/Sections/mixins/MaxSectionMixinTest.php b/tests/Cms/Sections/mixins/MaxSectionMixinTest.php index cae8bbae15..0c98ed4cb6 100644 --- a/tests/Cms/Sections/mixins/MaxSectionMixinTest.php +++ b/tests/Cms/Sections/mixins/MaxSectionMixinTest.php @@ -22,9 +22,7 @@ public function setUp(): void Section::$types['test'] = [ 'mixins' => ['max'], 'computed' => [ - 'total' => function () { - return 10; - } + 'total' => fn () => 10 ] ]; } diff --git a/tests/Cms/Sections/mixins/MinSectionMixinTest.php b/tests/Cms/Sections/mixins/MinSectionMixinTest.php index dbb3b86c11..d6464eba73 100644 --- a/tests/Cms/Sections/mixins/MinSectionMixinTest.php +++ b/tests/Cms/Sections/mixins/MinSectionMixinTest.php @@ -22,9 +22,7 @@ public function setUp(): void Section::$types['test'] = [ 'mixins' => ['min'], 'computed' => [ - 'total' => function () { - return 10; - } + 'total' => fn () => 10 ] ]; } diff --git a/tests/Cms/Sections/mixins/SortMixinTest.php b/tests/Cms/Sections/mixins/SortMixinTest.php index 682ff6c9de..d6eeb511d3 100644 --- a/tests/Cms/Sections/mixins/SortMixinTest.php +++ b/tests/Cms/Sections/mixins/SortMixinTest.php @@ -22,18 +22,14 @@ public function setUp(): void Section::$types['test'] = [ 'mixins' => ['sort'], 'props' => [ - 'query' => function (string|null $query = null) { - return $query; - } + 'query' => fn (string|null $query = null) => $query ] ]; Section::$types['pages'] = [ 'mixins' => ['sort'], 'props' => [ - 'status' => function (string|null $status = null) { - return $status; - }, + 'status' => fn (string|null $status = null) => $status ] ]; } diff --git a/tests/Cms/Site/SiteMethodsTest.php b/tests/Cms/Site/SiteMethodsTest.php index 7954cc170d..851be03406 100644 --- a/tests/Cms/Site/SiteMethodsTest.php +++ b/tests/Cms/Site/SiteMethodsTest.php @@ -12,9 +12,7 @@ public function setUp(): void { $this->app = new App([ 'siteMethods' => [ - 'test' => function () { - return 'site method'; - } + 'test' => fn () => 'site method' ], 'site' => [ 'children' => [ diff --git a/tests/Cms/Structures/StructureMethodsTest.php b/tests/Cms/Structures/StructureMethodsTest.php index 3b27e2af7a..6c1ebaae8e 100644 --- a/tests/Cms/Structures/StructureMethodsTest.php +++ b/tests/Cms/Structures/StructureMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'structureMethods' => [ - 'test' => function () { - return 'structure method'; - } + 'test' => fn () => 'structure method' ] ]); } diff --git a/tests/Cms/Structures/StructureObjectMethodsTest.php b/tests/Cms/Structures/StructureObjectMethodsTest.php index e94aa9e061..8079ef9b1b 100644 --- a/tests/Cms/Structures/StructureObjectMethodsTest.php +++ b/tests/Cms/Structures/StructureObjectMethodsTest.php @@ -15,9 +15,7 @@ public function setUp(): void 'index' => '/dev/null', ], 'structureObjectMethods' => [ - 'test' => function () { - return 'structure object method'; - } + 'test' => fn () => 'structure object method' ] ]); } diff --git a/tests/Cms/Users/UserTest.php b/tests/Cms/Users/UserTest.php index e57ed2382a..5fd7be1578 100644 --- a/tests/Cms/Users/UserTest.php +++ b/tests/Cms/Users/UserTest.php @@ -472,9 +472,7 @@ public function testQuery() public function testUserMethods() { User::$methods = [ - 'test' => function () { - return 'homer'; - } + 'test' => fn () => 'homer' ]; $user = new User([ diff --git a/tests/Content/FieldTest.php b/tests/Content/FieldTest.php index 6fcd6ba198..15ba6ddad7 100644 --- a/tests/Content/FieldTest.php +++ b/tests/Content/FieldTest.php @@ -118,9 +118,7 @@ public function testValueCallbackSetter() { $field = new Field(null, 'title', 'Title'); $this->assertSame('Title', $field->value()); - $field = $field->value(function ($value) { - return 'Modified'; - }); + $field = $field->value(fn ($value) => 'Modified'); $this->assertSame('Modified', $field->value()); } diff --git a/tests/Database/DbTest.php b/tests/Database/DbTest.php index df9dc7af04..3f2230b922 100644 --- a/tests/Database/DbTest.php +++ b/tests/Database/DbTest.php @@ -145,9 +145,7 @@ public function testCallStatic() 'prefix' => 'myprefix_' ]); - Db::$queries['test'] = function ($test) { - return $test . ' test'; - }; + Db::$queries['test'] = fn ($test) => $test . ' test'; $this->assertSame('This is a test', Db::test('This is a')); unset(Db::$queries['test']); diff --git a/tests/Database/QueryTest.php b/tests/Database/QueryTest.php index 4a5eb4d456..28e36f8e9a 100644 --- a/tests/Database/QueryTest.php +++ b/tests/Database/QueryTest.php @@ -335,9 +335,7 @@ public function testFetch() ->table('users') ->where(['username' => 'john']); - $x = function ($row, $key) { - return $row['fname'] . ' ' . $row['lname']; - }; + $x = fn ($row, $key) => $row['fname'] . ' ' . $row['lname']; $this->assertSame('John Lennon', (clone $query)->fetch($x)->first()); $this->assertSame('John Lennon', (clone $query)->fetch([$this, 'fetchTestCallable'])->first()); diff --git a/tests/Email/EmailTest.php b/tests/Email/EmailTest.php index 373d33ea27..0f02323986 100644 --- a/tests/Email/EmailTest.php +++ b/tests/Email/EmailTest.php @@ -206,9 +206,7 @@ public function testBeforeSend() // invalid $mail = $this->_email([ 'transport' => $transport, - 'beforeSend' => $beforeSend = function ($mailer) { - return 'string'; - } + 'beforeSend' => $beforeSend = fn ($mailer) => 'string' ], PHPMailer::class); $this->expectException(InvalidArgumentException::class); diff --git a/tests/Filesystem/AssetTest.php b/tests/Filesystem/AssetTest.php index f574afe189..6d91f679df 100644 --- a/tests/Filesystem/AssetTest.php +++ b/tests/Filesystem/AssetTest.php @@ -23,9 +23,7 @@ public function setUp(): void 'index' => 'https://getkirby.com' ], 'assetMethods' => [ - 'test' => function () { - return 'asset method'; - } + 'test' => fn () => 'asset method' ] ]); } diff --git a/tests/Form/FieldTest.php b/tests/Form/FieldTest.php index 6a2cdc616f..c3f235eb36 100644 --- a/tests/Form/FieldTest.php +++ b/tests/Form/FieldTest.php @@ -235,9 +235,7 @@ public function testDialogs() // return routes Field::$types = [ 'test' => [ - 'dialogs' => function () use ($routes) { - return $routes; - } + 'dialogs' => fn () => $routes ] ]; @@ -360,9 +358,7 @@ public function testIcon() Field::$types = [ 'test' => [ 'props' => [ - 'icon' => function (string $icon = 'test') { - return $icon; - } + 'icon' => fn (string $icon = 'test') => $icon ] ] ]; @@ -411,9 +407,7 @@ public function testIsEmptyWithCustomFunction() { Field::$types = [ 'test' => [ - 'isEmpty' => function ($value) { - return $value === 0; - } + 'isEmpty' => fn ($value) => $value === 0 ] ]; @@ -675,13 +669,9 @@ public function testSaveHandler() Field::$types = [ 'test' => [ 'props' => [ - 'value' => function ($value) { - return $value; - } + 'value' => fn ($value) => $value ], - 'save' => function ($value) { - return implode(', ', $value); - } + 'save' => fn ($value) => implode(', ', $value) ] ]; @@ -700,9 +690,7 @@ public function testToArray() Field::$types = [ 'test' => [ 'props' => [ - 'foo' => function ($foo) { - return $foo; - } + 'foo' => fn ($foo) => $foo ] ] ]; @@ -998,9 +986,7 @@ public function testApi() // return simple string Field::$types = [ 'test' => [ - 'api' => function () { - return 'Hello World'; - } + 'api' => fn () => 'Hello World' ] ]; diff --git a/tests/Form/Fields/Mixins/FilePickerMixinTest.php b/tests/Form/Fields/Mixins/FilePickerMixinTest.php index e49af812ee..edabe94c82 100644 --- a/tests/Form/Fields/Mixins/FilePickerMixinTest.php +++ b/tests/Form/Fields/Mixins/FilePickerMixinTest.php @@ -34,9 +34,7 @@ public function testPageFiles() 'test' => [ 'mixins' => ['filepicker'], 'methods' => [ - 'files' => function () { - return $this->filepicker()['data']; - } + 'files' => fn () => $this->filepicker()['data'] ] ] ]; @@ -68,9 +66,7 @@ public function testFileFiles() 'test' => [ 'mixins' => ['filepicker'], 'methods' => [ - 'files' => function () { - return $this->filepicker()['data']; - } + 'files' => fn () => $this->filepicker()['data'] ] ] ]; @@ -102,9 +98,7 @@ public function testUserFiles() 'test' => [ 'mixins' => ['filepicker'], 'methods' => [ - 'files' => function () { - return $this->filepicker()['data']; - } + 'files' => fn () => $this->filepicker()['data'] ] ] ]; @@ -136,9 +130,7 @@ public function testSiteFiles() 'test' => [ 'mixins' => ['filepicker'], 'methods' => [ - 'files' => function () { - return $this->filepicker()['data']; - } + 'files' => fn () => $this->filepicker()['data'] ] ] ]; @@ -169,16 +161,12 @@ public function testCustomQuery() 'test' => [ 'mixins' => ['filepicker'], 'props' => [ - 'query' => function (string|null $query = null) { - return $query; - } + 'query' => fn (string|null $query = null) => $query ], 'methods' => [ - 'files' => function () { - return $this->filepicker([ - 'query' => $this->query - ])['data']; - } + 'files' => fn () => $this->filepicker([ + 'query' => $this->query + ])['data'] ] ] ]; @@ -213,18 +201,12 @@ public function testMap() 'test' => [ 'mixins' => ['filepicker'], 'props' => [ - 'query' => function (string|null $query = null) { - return $query; - } + 'query' => fn (string|null $query = null) => $query ], 'methods' => [ - 'files' => function () { - return $this->filepicker([ - 'map' => function ($file) { - return $file->id(); - } - ])['data']; - } + 'files' => fn () => $this->filepicker([ + 'map' => fn ($file) => $file->id() + ])['data'] ] ] ]; diff --git a/tests/Form/Fields/Mixins/PagePickerMixinTest.php b/tests/Form/Fields/Mixins/PagePickerMixinTest.php index bd51252302..7cead2b9a6 100644 --- a/tests/Form/Fields/Mixins/PagePickerMixinTest.php +++ b/tests/Form/Fields/Mixins/PagePickerMixinTest.php @@ -23,9 +23,7 @@ public function testPagesWithoutParent() 'test' => [ 'mixins' => ['pagepicker'], 'methods' => [ - 'pages' => function () { - return $this->pagepicker(); - } + 'pages' => fn () => $this->pagepicker() ] ] ], @@ -68,11 +66,9 @@ public function testPagesWithParent() 'test' => [ 'mixins' => ['pagepicker'], 'methods' => [ - 'pages' => function () { - return $this->pagepicker([ - 'parent' => 'a' - ]); - } + 'pages' => fn () => $this->pagepicker([ + 'parent' => 'a' + ]) ] ] ], @@ -118,11 +114,9 @@ public function testPageChildren() 'test' => [ 'mixins' => ['pagepicker'], 'methods' => [ - 'pages' => function () { - return $this->pagepicker([ - 'query' => 'page.children' - ]); - } + 'pages' => fn () => $this->pagepicker([ + 'query' => 'page.children' + ]) ] ] ], @@ -170,12 +164,10 @@ public function testPageChildrenWithoutSubpages() 'test' => [ 'mixins' => ['pagepicker'], 'methods' => [ - 'pages' => function () { - return $this->pagepicker([ - 'query' => 'page.children', - 'subpages' => false - ]); - } + 'pages' => fn () => $this->pagepicker([ + 'query' => 'page.children', + 'subpages' => false + ]) ] ] ], @@ -219,14 +211,10 @@ public function testMap() 'test' => [ 'mixins' => ['pagepicker'], 'methods' => [ - 'pages' => function () { - return $this->pagepicker([ - 'query' => 'page.children', - 'map' => function ($page) { - return $page->id(); - } - ]); - } + 'pages' => fn () => $this->pagepicker([ + 'query' => 'page.children', + 'map' => fn ($page) => $page->id() + ]) ] ] ], diff --git a/tests/Form/Fields/Mixins/UserPickerMixinTest.php b/tests/Form/Fields/Mixins/UserPickerMixinTest.php index f06436a743..67220f47b1 100644 --- a/tests/Form/Fields/Mixins/UserPickerMixinTest.php +++ b/tests/Form/Fields/Mixins/UserPickerMixinTest.php @@ -36,9 +36,7 @@ public function testUsersWithoutQuery() 'test' => [ 'mixins' => ['userpicker'], 'methods' => [ - 'users' => function () { - return $this->userpicker()['data']; - } + 'users' => fn () => $this->userpicker()['data'] ] ] ]; @@ -65,11 +63,9 @@ public function testUsersWithQuery() 'test' => [ 'mixins' => ['userpicker'], 'methods' => [ - 'users' => function () { - return $this->userpicker([ - 'query' => 'kirby.users.role("editor")' - ])['data']; - } + 'users' => fn () => $this->userpicker([ + 'query' => 'kirby.users.role("editor")' + ])['data'] ] ] ]; @@ -95,13 +91,9 @@ public function testMap() 'test' => [ 'mixins' => ['userpicker'], 'methods' => [ - 'users' => function () { - return $this->userpicker([ - 'map' => function ($user) { - return $user->email(); - } - ])['data']; - } + 'users' => fn () => $this->userpicker([ + 'map' => fn ($user) => $user->email() + ])['data'] ] ] ]; diff --git a/tests/Form/FormTest.php b/tests/Form/FormTest.php index 963f2611c7..ae4464df6a 100644 --- a/tests/Form/FormTest.php +++ b/tests/Form/FormTest.php @@ -418,12 +418,8 @@ public function testPageFormWithClosures() $form = Form::for($page, [ 'values' => [ - 'a' => function ($value) { - return $value . 'A'; - }, - 'b' => function ($value) { - return $value . 'B'; - }, + 'a' => fn ($value) => $value . 'A', + 'b' => fn ($value) => $value . 'B' ] ]); diff --git a/tests/Form/ValidationsTest.php b/tests/Form/ValidationsTest.php index 1df3ba2db8..b623e86ced 100644 --- a/tests/Form/ValidationsTest.php +++ b/tests/Form/ValidationsTest.php @@ -20,9 +20,7 @@ public function setUp(): void Field::$types = [ 'test' => [ 'props' => [ - 'options' => function (array $options = []) { - return $options; - } + 'options' => fn (array $options = []) => $options ] ] ]; diff --git a/tests/Http/ResponseTest.php b/tests/Http/ResponseTest.php index 5d747ac9c7..a3da4dcc7a 100644 --- a/tests/Http/ResponseTest.php +++ b/tests/Http/ResponseTest.php @@ -98,9 +98,11 @@ public function testDownloadWithMissingFile() */ public function testGuardAgainstOutput() { - $result = Response::guardAgainstOutput(function ($arg1, $arg2) { - return $arg1 . '-' . $arg2; - }, '12', '34'); + $result = Response::guardAgainstOutput( + fn ($arg1, $arg2) => $arg1 . '-' . $arg2, + '12', + '34' + ); $this->assertSame('12-34', $result); } @@ -112,9 +114,11 @@ public function testGuardAgainstOutputWithSubsequentOutput() { HeadersSent::$value = true; - $result = Response::guardAgainstOutput(function ($arg1, $arg2) { - return $arg1 . '-' . $arg2; - }, '12', '34'); + $result = Response::guardAgainstOutput( + fn ($arg1, $arg2) => $arg1 . '-' . $arg2, + '12', + '34' + ); $this->assertSame('12-34', $result); } diff --git a/tests/Http/RouteTest.php b/tests/Http/RouteTest.php index e34b25e48d..65a4bb4223 100644 --- a/tests/Http/RouteTest.php +++ b/tests/Http/RouteTest.php @@ -15,9 +15,7 @@ public function _route() public function testConstruct() { - $route = new Route('/', 'POST', $func = function () { - return 'test'; - }); + $route = new Route('/', 'POST', $func = fn () => 'test'); $this->assertSame('', $route->pattern()); $this->assertSame('POST', $route->method()); diff --git a/tests/Http/RouterTest.php b/tests/Http/RouterTest.php index fd865dfa39..ea87dfdcb2 100644 --- a/tests/Http/RouterTest.php +++ b/tests/Http/RouterTest.php @@ -135,9 +135,7 @@ public function testAfterEach() [ [ 'pattern' => '/', - 'action' => function () { - return 'test'; - } + 'action' => fn () => 'test' ] ], $hooks @@ -225,9 +223,7 @@ public function testNextAfterEach() ], [ 'pattern' => 'a', - 'action' => function () { - return 'a'; - } + 'action' => fn () => 'a' ] ], $hooks diff --git a/tests/Panel/Areas/PluginSearchesTest.php b/tests/Panel/Areas/PluginSearchesTest.php index 8c00d44fec..2039816a35 100644 --- a/tests/Panel/Areas/PluginSearchesTest.php +++ b/tests/Panel/Areas/PluginSearchesTest.php @@ -22,9 +22,7 @@ public function testLegacyPluginSearch(): void 'search' => 'test', 'searches' => [ 'test' => [ - 'query' => function (string|null $query = null) { - return [['a'], ['b'], ['c']]; - }, + 'query' => fn (string|null $query = null) => [['a'], ['b'], ['c']] ] ] ] diff --git a/tests/Panel/Areas/PluginTest.php b/tests/Panel/Areas/PluginTest.php index 049e25db4f..bc148b6f22 100644 --- a/tests/Panel/Areas/PluginTest.php +++ b/tests/Panel/Areas/PluginTest.php @@ -14,11 +14,9 @@ public function testView(): void 'views' => [ [ 'pattern' => 'foo', - 'action' => function () { - return [ - 'component' => 'k-foo-view' - ]; - } + 'action' => fn () => [ + 'component' => 'k-foo-view' + ] ] ] ] @@ -40,21 +38,17 @@ public function testViewWhen(): void 'views' => [ [ 'pattern' => 'foo', - 'when' => fn () => true, - 'action' => function () { - return [ - 'component' => 'k-foo-view', - ]; - } + 'when' => fn () => true, + 'action' => fn () => [ + 'component' => 'k-foo-view', + ] ], [ 'pattern' => 'bar', - 'when' => fn () => false, - 'action' => function () { - return [ - 'component' => 'k-bar-view', - ]; - } + 'when' => fn () => false, + 'action' => fn () => [ + 'component' => 'k-bar-view', + ] ] ] ] diff --git a/tests/Panel/DropdownTest.php b/tests/Panel/DropdownTest.php index c5a68638af..8bfa602fe7 100644 --- a/tests/Panel/DropdownTest.php +++ b/tests/Panel/DropdownTest.php @@ -148,14 +148,12 @@ public function testRoutes(): void { $dropdown = [ 'pattern' => 'test', - 'action' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'action' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ]; $routes = Dropdown::routes( @@ -187,14 +185,12 @@ public function testRoutesForDropdownsWithOptions(): void 'dropdowns' => [ 'test' => [ 'pattern' => 'test', - 'options' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'options' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ] ] ]; @@ -221,14 +217,12 @@ public function testRoutesForDropdownsWithShortcut(): void { $area = [ 'dropdowns' => [ - 'test' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'test' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ] ]; diff --git a/tests/Panel/FileTest.php b/tests/Panel/FileTest.php index 56f4c18526..85fb810863 100644 --- a/tests/Panel/FileTest.php +++ b/tests/Panel/FileTest.php @@ -254,7 +254,7 @@ public function testDragTextCustomMarkdown() 'panel' => [ 'kirbytext' => false, 'markdown' => [ - 'fileDragText' => function (\Kirby\Cms\File $file, string $url) { + 'fileDragText' => function (ModelFile $file, string $url) { if ($file->extension() === 'heic') { return sprintf('![](%s)', $url); } @@ -295,7 +295,7 @@ public function testDragTextCustomKirbytext() 'options' => [ 'panel' => [ 'kirbytext' => [ - 'fileDragText' => function (\Kirby\Cms\File $file, string $url) { + 'fileDragText' => function (ModelFile $file, string $url) { if ($file->extension() === 'heic') { return sprintf('(image: %s)', $url); } diff --git a/tests/Panel/ModelTest.php b/tests/Panel/ModelTest.php index 0eec3d104f..988523dcdf 100644 --- a/tests/Panel/ModelTest.php +++ b/tests/Panel/ModelTest.php @@ -4,6 +4,7 @@ use Kirby\Cms\App; use Kirby\Cms\ContentLock; +use Kirby\Cms\File as ModelFile; use Kirby\Cms\Page as ModelPage; use Kirby\Cms\Site as ModelSite; use Kirby\Filesystem\Asset; @@ -150,7 +151,7 @@ public function testDragTextFromCallbackMarkdown() 'options' => [ 'panel' => [ 'markdown' => [ - 'fileDragText' => function (\Kirby\Cms\File $file, string $url) { + 'fileDragText' => function (ModelFile $file, string $url) { if ($file->extension() === 'heic') { return sprintf('![](%s)', $file->id()); } @@ -193,7 +194,7 @@ public function testDragTextFromCallbackKirbytext() 'options' => [ 'panel' => [ 'kirbytext' => [ - 'fileDragText' => function (\Kirby\Cms\File $file, string $url) { + 'fileDragText' => function (ModelFile $file, string $url) { if ($file->extension() === 'heic') { return sprintf('(image: %s)', $file->id()); } diff --git a/tests/Panel/PageTest.php b/tests/Panel/PageTest.php index 279f6b75ea..7f96953ebf 100644 --- a/tests/Panel/PageTest.php +++ b/tests/Panel/PageTest.php @@ -178,7 +178,7 @@ public function testDragTextCustomMarkdown() 'panel' => [ 'kirbytext' => false, 'markdown' => [ - 'pageDragText' => function (\Kirby\Cms\Page $page) { + 'pageDragText' => function (ModelPage $page) { return sprintf('Links sind toll: %s', $page->url()); }, ] @@ -209,7 +209,7 @@ public function testDragTextCustomKirbytext() 'options' => [ 'panel' => [ 'kirbytext' => [ - 'pageDragText' => function (\Kirby\Cms\Page $page) { + 'pageDragText' => function (ModelPage $page) { return sprintf('Links sind toll: %s', $page->url()); }, ] diff --git a/tests/Panel/PanelTest.php b/tests/Panel/PanelTest.php index 564ecfe332..a9e53c6f7e 100644 --- a/tests/Panel/PanelTest.php +++ b/tests/Panel/PanelTest.php @@ -539,14 +539,12 @@ public function testRoutesForDropdowns(): void 'dropdowns' => [ 'test' => [ 'pattern' => 'test', - 'action' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'action' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ] ] ]; @@ -575,14 +573,12 @@ public function testRoutesForDropdownsWithOptions(): void 'dropdowns' => [ 'test' => [ 'pattern' => 'test', - 'options' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'options' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ] ] ]; @@ -609,14 +605,12 @@ public function testRoutesForDropdownsWithShortcut(): void { $area = [ 'dropdowns' => [ - 'test' => $action = function () { - return [ - [ - 'text' => 'Test', - 'link' => '/test' - ] - ]; - } + 'test' => $action = fn () => [ + [ + 'text' => 'Test', + 'link' => '/test' + ] + ] ] ]; diff --git a/tests/Query/QueryDefaultFunctionsTest.php b/tests/Query/QueryDefaultFunctionsTest.php index 09540d87ae..1fd486a5f1 100644 --- a/tests/Query/QueryDefaultFunctionsTest.php +++ b/tests/Query/QueryDefaultFunctionsTest.php @@ -35,9 +35,7 @@ public function testCollection() ] ], 'collections' => [ - 'test' => function ($pages) { - return $pages; - } + 'test' => fn ($pages) => $pages ] ]); diff --git a/tests/Toolkit/CollectionConverterTest.php b/tests/Toolkit/CollectionConverterTest.php index 991d87af19..c8c0864840 100644 --- a/tests/Toolkit/CollectionConverterTest.php +++ b/tests/Toolkit/CollectionConverterTest.php @@ -23,9 +23,7 @@ public function testToArrayMap() $this->assertSame([ 'one' => 'einsy', 'two' => 'zweiy' - ], $collection->toArray(function ($item) { - return $item . 'y'; - })); + ], $collection->toArray(fn ($item) => $item . 'y')); } public function testToJson() diff --git a/tests/Toolkit/CollectionMutatorTest.php b/tests/Toolkit/CollectionMutatorTest.php index 0f56321123..6801718632 100644 --- a/tests/Toolkit/CollectionMutatorTest.php +++ b/tests/Toolkit/CollectionMutatorTest.php @@ -130,9 +130,7 @@ public function testMap() ]); $this->assertSame('zwei', $collection->two()); - $collection->map(function ($item) { - return $item . '-ish'; - }); + $collection->map(fn ($item) => $item . '-ish'); $this->assertSame('zwei-ish', $collection->two()); } diff --git a/tests/Toolkit/CollectionTest.php b/tests/Toolkit/CollectionTest.php index 3d77123474..ce9f7a893f 100644 --- a/tests/Toolkit/CollectionTest.php +++ b/tests/Toolkit/CollectionTest.php @@ -183,11 +183,9 @@ public function testEmpty() */ public function testFilter() { - $func = function ($element) { - return ($element === 'My second element') ? true : false; - }; - - $filtered = $this->collection->filter($func); + $filtered = $this->collection->filter( + fn ($element) => $element === 'My second element' + ); $this->assertSame('My second element', $filtered->first()); $this->assertSame('My second element', $filtered->last()); @@ -336,9 +334,7 @@ public function testGroupWithInvalidKey() $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid grouping value for key: a'); - $collection->group(function ($item) { - return false; - }); + $collection->group(fn ($item) => false); } /** @@ -389,10 +385,7 @@ public function testGroupStringObject() 'group' => new StringObject('client') ]; - $groups = $collection->group(function ($item) { - return $item['group']; - }); - + $groups = $collection->group(fn ($item) => $item['group']); $this->assertCount(2, $groups->admin()); $this->assertCount(1, $groups->client()); @@ -982,9 +975,9 @@ public function testValues() */ public function testValuesMap() { - $values = $this->collection->values(function ($item) { - return Str::after($item, 'My '); - }); + $values = $this->collection->values( + fn ($item) => Str::after($item, 'My ') + ); $this->assertSame([ 'first element', diff --git a/tests/Toolkit/DomTest.php b/tests/Toolkit/DomTest.php index 9a65724929..5d8c56ba82 100644 --- a/tests/Toolkit/DomTest.php +++ b/tests/Toolkit/DomTest.php @@ -1850,9 +1850,10 @@ public function testSanitize(string $code, array $options, string $expectedCode, $dom = new Dom($code, 'XML'); $errors = $dom->sanitize($options); - $this->assertSame($expectedErrors, array_map(function ($error) { - return $error->getMessage(); - }, $errors)); + $this->assertSame( + $expectedErrors, + array_map(fn ($error) => $error->getMessage(), $errors) + ); $this->assertSame($expectedCode, $dom->toString()); } diff --git a/tests/Toolkit/I18nTest.php b/tests/Toolkit/I18nTest.php index 458115e091..08a628603e 100644 --- a/tests/Toolkit/I18nTest.php +++ b/tests/Toolkit/I18nTest.php @@ -430,17 +430,11 @@ public function testTranslateCountWithCallback() { I18n::$translations = [ 'en' => [ - 'car' => function ($count) { - switch ($count) { - case 0: - return 'No car'; - case 1: - return 'One car'; - case in_array($count, [2, 3, 4]) === true: - return 'Few cars'; - default: - return 'Many cars'; - } + 'car' => fn ($count) => match ($count) { + 0 => 'No car', + 1 => 'One car', + 2, 3, 4 => 'Few cars', + default => 'Many cars' } ] ];