diff --git a/src/BaseListView.php b/src/BaseListView.php index d864dc74c..3f2ef2c08 100644 --- a/src/BaseListView.php +++ b/src/BaseListView.php @@ -34,6 +34,9 @@ use Yiisoft\Data\Reader\OrderHelper; use Yiisoft\Yii\DataView\Exception\DataReaderNotSetException; +use function is_array; +use function is_string; + /** * @psalm-type UrlArguments = array * @psalm-type UrlCreator = callable(UrlArguments,array):string diff --git a/src/BasePagination.php b/src/BasePagination.php index 76d1093c1..4b194143f 100644 --- a/src/BasePagination.php +++ b/src/BasePagination.php @@ -10,6 +10,8 @@ use Yiisoft\Html\Html; use Yiisoft\Widget\Widget; +use function call_user_func_array; + /** * @psalm-import-type UrlCreator from BaseListView */ diff --git a/src/Column/DataColumnRenderer.php b/src/Column/DataColumnRenderer.php index 311ca595b..7365e7591 100644 --- a/src/Column/DataColumnRenderer.php +++ b/src/Column/DataColumnRenderer.php @@ -28,6 +28,7 @@ use function is_array; use function is_callable; +use function is_string; /** * @psalm-import-type FilterEmptyCallable from DataColumn diff --git a/src/Filter/Factory/LikeFilterFactory.php b/src/Filter/Factory/LikeFilterFactory.php index 34f48c730..a0becb491 100644 --- a/src/Filter/Factory/LikeFilterFactory.php +++ b/src/Filter/Factory/LikeFilterFactory.php @@ -5,16 +5,20 @@ namespace Yiisoft\Yii\DataView\Filter\Factory; use Yiisoft\Data\Reader\Filter\Like; -use Yiisoft\Data\Reader\FilterInterface; final class LikeFilterFactory implements FilterFactoryInterface { - public function create(string $property, string $value): ?FilterInterface + public function __construct( + private readonly ?bool $caseSensitive = null, + ) { + } + + public function create(string $property, string $value): ?Like { if (empty($value)) { return null; } - return new Like($property, $value); + return new Like($property, $value, $this->caseSensitive); } } diff --git a/src/ListView.php b/src/ListView.php index e2a1b4926..d510759de 100644 --- a/src/ListView.php +++ b/src/ListView.php @@ -10,6 +10,8 @@ use Yiisoft\View\Exception\ViewNotFoundException; use Yiisoft\View\View; +use function is_string; + /** * The ListView widget displays data from data provider. Each data model is rendered using the view specified. */ diff --git a/tests/Filter/Factory/LikeFilterFactoryTest.php b/tests/Filter/Factory/LikeFilterFactoryTest.php new file mode 100644 index 000000000..3bb936ca7 --- /dev/null +++ b/tests/Filter/Factory/LikeFilterFactoryTest.php @@ -0,0 +1,40 @@ +create('name', 'John'); + + $this->assertSame('name', $filter->getField()); + $this->assertSame('John', $filter->getValue()); + $this->assertNull($filter->isCaseSensitive()); + } + + public static function dataCaseSensitive(): iterable + { + yield [null]; + yield [true]; + yield [false]; + } + + #[DataProvider('dataCaseSensitive')] + public function testCaseSensitive(?bool $value): void + { + $factory = new LikeFilterFactory($value); + + $filter = $factory->create('name', 'John'); + + $this->assertSame($value, $filter->isCaseSensitive()); + } +}