diff --git a/src/TailwindRuntime.php b/src/TailwindRuntime.php index cd6549d..57fbd26 100644 --- a/src/TailwindRuntime.php +++ b/src/TailwindRuntime.php @@ -22,7 +22,7 @@ public function __construct(?CacheInterface $cache = null) $this->factory = TailwindMerge::factory()->withCache(new Psr16Cache($cache)); } - public function merge(string|array $classes, array $configuration = []): string + public function merge(string|array|null $classes, array $configuration = []): string { return $this->factory ->withConfiguration($configuration) diff --git a/tests/Fixtures/filters/tailwind_merge.test b/tests/Fixtures/filters/tailwind_merge.test index 0ab093f..143e493 100644 --- a/tests/Fixtures/filters/tailwind_merge.test +++ b/tests/Fixtures/filters/tailwind_merge.test @@ -5,6 +5,7 @@ {{ "block inline"|tailwind_merge }} {{ classes|tailwind_merge }} {{ "tw-text-red-500 tw-text-blue-500"|tailwind_merge({prefix: 'tw-'}) }} +{{ null|tailwind_merge }} --DATA-- return [ 'classes' => ['h-10', 'h-20'], diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 9af7a97..2d81ea0 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -31,4 +31,11 @@ public function testItCanMergeWithConfiguration(): void $this->assertSame('tw-text-blue-500', $runtime->merge(['tw-text-red-500', 'tw-text-blue-500'], ['prefix' => 'tw-'])); } + + public function testItWillReturnEmptyStringIfSuppliedNull(): void + { + $runtime = new TailwindRuntime(); + + $this->assertSame('', $runtime->merge(null)); + } }