Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
samdark and vjik authored Feb 8, 2025
1 parent a453b43 commit 32bef46
Show file tree
Hide file tree
Showing 33 changed files with 63 additions and 61 deletions.
1 change: 0 additions & 1 deletion docs/en/guide/detailview.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ the following:
- `valueAttributes` - An array of value's HTML attribute values indexed by attribute names or a function accepting
data and returning the array.


## Rendering options

The widget is fully customizable in terms of how it's rendered.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/guide/listview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List view
# List View

The `ListView` widget is designed to display a list of data items.
It provides a flexible way to render data in a list format,
Expand Down
2 changes: 1 addition & 1 deletion src/BaseListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
use function is_int;

/**
* BaseListView is an abstract base class for widgets that display data items in terms of a list or grid.
* `BaseListView` is an abstract base class for widgets that display data items in terms of a list or grid.
*
* @psalm-type UrlArguments = array<string,scalar|Stringable|null>
* @psalm-type UrlCreator = callable(UrlArguments,array):string
Expand Down
2 changes: 1 addition & 1 deletion src/BodyRowContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Yiisoft\Yii\DataView;

/**
* BodyRowContext provides contextual information for rendering a table body row in data views.
* `BodyRowContext` provides contextual information for rendering a table body row in data views.
*/
final class BodyRowContext
{
Expand Down
6 changes: 4 additions & 2 deletions src/Column/ActionButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Stringable;

/**
* ActionButton represents a button in an action column of a grid.
* `ActionButton` represents a button in an action column of a grid.
*/
final class ActionButton
{
Expand All @@ -19,10 +19,12 @@ final class ActionButton
* `function(array|object $data, DataContext $context): string`.
* @param array|Closure|null $attributes HTML attributes. If closure is used, its signature is:
* `function(array|object $data, DataContext $context): array`.
* @param array<array-key,string|null>|Closure|false|string|null $class CSS class(es). If closure is used, its signature is:
* @param array|Closure|false|string|null $class CSS class(es). If closure is used, its signature is:
* `function(array|object $data, DataContext $context): string|array<array-key,string|null>|null`.
* @param string|null $title Button title attribute.
* @param bool $overrideAttributes Whether to override default attributes with custom ones instead of merging.
*
* @psalm-param array<array-key,string|null>|Closure|false|string|null $class
*/
public function __construct(
public readonly Closure|string|Stringable $content = '',
Expand Down
6 changes: 4 additions & 2 deletions src/Column/ActionColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
final class ActionColumn implements ColumnInterface
{
/**
* @var UrlCreator|null URL creator callback.
* @var callable|null URL creator callback.
*
* @psalm-var UrlCreator|null
*/
private $urlCreator;

Expand All @@ -40,7 +42,7 @@ final class ActionColumn implements ColumnInterface
* @param bool $visible Whether the column is visible.
*
* @psalm-param UrlCreator|null $urlCreator
* @psalm-param array<string, ButtonRenderer>|null $buttons
* @psalm-param array<array-key, ButtonRenderer>|null $buttons
* @psalm-param array<string, bool|Closure>|null $visibleButtons
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Column/ActionColumnRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use function is_callable;

/**
* ActionColumnRenderer renders action buttons in a grid column.
* `ActionColumnRenderer` renders action buttons in a grid column.
*
* @psalm-import-type UrlCreator from ActionColumn
* @psalm-import-type ButtonRenderer from ActionColumn
Expand Down
4 changes: 2 additions & 2 deletions src/Column/Base/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Yiisoft\Html\NoEncodeStringableInterface;

/**
* Cell represents a single grid cell with content and attributes.
* `Cell` represents a single grid cell with content and attributes.
*/
final class Cell
{
Expand Down Expand Up @@ -200,7 +200,7 @@ public function shouldDoubleEncode(): bool
/**
* Get cell content parts.
*
* @return array<array-key,string|Stringable> Array of content parts.
* @return array Array of content parts.
*
* @psalm-return array<array-key,string|Stringable>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Base/DataContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Yiisoft\Yii\DataView\Column\ColumnInterface;

/**
* DataContext provides context information for rendering a data cell in a grid.
* `DataContext` provides context information for rendering a data cell in a grid.
*/
final class DataContext
{
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Base/FilterContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Yiisoft\Yii\DataView\UrlParameterType;

/**
* FilterContext provides context information for rendering and handling grid column filters.
* `FilterContext` provides context information for rendering and handling grid column filters.
*/
final class FilterContext
{
Expand Down
4 changes: 2 additions & 2 deletions src/Column/Base/GlobalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
use Yiisoft\Translator\TranslatorInterface;

/**
* GlobalContext provides shared context for all columns in a grid.
* `GlobalContext` provides shared context for all columns in a grid.
*/
final class GlobalContext
{
/**
* Creates a new global context instance.
*
* @param ReadableDataInterface $dataReader Data reader for accessing grid data.
* @param array<string,scalar|Stringable|null> $pathArguments URL path arguments for link generation.
* @param array $pathArguments URL path arguments for link generation.
* @psalm-param array<string,scalar|Stringable|null> $pathArguments
* @param array $queryParameters URL query parameters for link generation.
* @param TranslatorInterface $translator Translator service for internationalizing grid content.
Expand Down
4 changes: 2 additions & 2 deletions src/Column/Base/HeaderContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use function count;

/**
* HeaderContext provides context for rendering and handling grid column headers.
* `HeaderContext` provides context for rendering and handling grid column headers.
*
* @psalm-import-type UrlCreator from BaseListView
*/
Expand All @@ -31,7 +31,7 @@ final class HeaderContext
*
* @param Sort|null $originalSort Original sort configuration before any modifications.
* @param Sort|null $sort Current sort configuration that reflects the active sort state.
* @param array<string, string> $orderProperties Map of field names to their sort properties.
* @param array $orderProperties Map of field names to their sort properties.
* @param string|null $sortableHeaderClass CSS class for sortable headers.
* @param string|Stringable $sortableHeaderPrepend Content to prepend to sortable headers.
* @param string|Stringable $sortableHeaderAppend Content to append to sortable headers.
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Base/MakeFilterContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Yiisoft\Yii\DataView\UrlParameterType;

/**
* MakeFilterContext provides context for creating and validating grid column filters.
* `MakeFilterContext` provides context for creating and validating grid column filters.
*/
final class MakeFilterContext
{
Expand Down
2 changes: 1 addition & 1 deletion src/Column/Base/RendererContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Yiisoft\Yii\DataView\Column\ColumnRendererInterface;

/**
* RendererContainer manages the creation and configuration of column renderers.
* `RendererContainer` manages the creation and configuration of column renderers.
*
* @internal This class is not part of the public API and may change without notice.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Column/CheckboxColumnRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Yiisoft\Yii\DataView\Column\Base\HeaderContext;

/**
* CheckboxColumnRenderer renders checkbox inputs in a grid column.
* `CheckboxColumnRenderer` renders checkbox inputs in a grid column.
*
* @implements ColumnRendererInterface<CheckboxColumn>
*/
Expand Down
14 changes: 7 additions & 7 deletions src/Column/DataColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Yiisoft\Yii\DataView\Filter\Widget\FilterWidget;

/**
* DataColumn is the default column type for the {@see GridView} widget.
* `DataColumn` is the default column type for the {@see GridView} widget.
*
* A simple data column definition refers to an attribute in the GridView's data provider.
*
Expand All @@ -23,7 +23,7 @@ final class DataColumn implements ColumnInterface
* Function to determine if a filter value should be considered empty.
*
* This property can be:
* - `null`: Uses default empty value checking (empty() function)
* - `null`: Uses default empty value checking (`empty()` function)
* - `true`: Always considers the value empty (disables filtering)
* - `false`: Always considers the value non-empty (enables filtering)
* - `callable`: Custom function to determine emptiness with signature:
Expand All @@ -40,7 +40,7 @@ final class DataColumn implements ColumnInterface
public readonly mixed $filterEmpty;

/**
* Creates a new DataColumn instance.
* Creates a new `DataColumn` instance.
*
* ```php
* // Basic usage
Expand Down Expand Up @@ -83,14 +83,14 @@ final class DataColumn implements ColumnInterface
* `function(array|object $data, DataContext $context): string|Stringable`.
* @param string|null $dateTimeFormat Format string for datetime values (e.g., 'Y-m-d H:i:s').
* @param array|bool|FilterWidget $filter Filter configuration. Can be:
* - false (disabled)
* - array (filter options)
* - FilterWidget instance (custom filter widget)
* - `false` (disabled)
* - `array` (filter options)
* - `FilterWidget` instance (custom filter widget)
* @param FilterFactoryInterface|string|null $filterFactory Factory for creating filter widgets.
* @param array|RuleInterface|null $filterValidation Validation rules for filter values.
* Can be a single rule or array of rules.
* @param bool|callable|null $filterEmpty Function to determine if a filter value is empty. Can be:
* - `null`: Uses default empty value checking (empty() function)
* - `null`: Uses default empty value checking (`empty()` function)
* - `true`: Always considers the value empty (disables filtering)
* - `false`: Always considers the value non-empty (enables filtering)
* - `callable`: Custom function to determine emptiness with signature:
Expand Down
4 changes: 2 additions & 2 deletions src/Column/DataColumnRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use function is_string;

/**
* DataColumnRenderer handles rendering and filtering of data columns in a grid.
* `DataColumnRenderer` handles rendering and filtering of data columns in a grid.
*
* @template TColumn as DataColumn
* @implements FilterableColumnRendererInterface<TColumn>
Expand All @@ -49,7 +49,7 @@ final class DataColumnRenderer implements FilterableColumnRendererInterface, Sor
private readonly mixed $defaultFilterEmpty;

/**
* Creates a new DataColumnRenderer instance.
* Creates a new `DataColumnRenderer` instance.
*
* @param ContainerInterface $filterFactoryContainer Container for filter factory instances.
* @param ValidatorInterface $validator Validator for filter values.
Expand Down
4 changes: 2 additions & 2 deletions src/Column/RadioColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use Closure;

/**
* RadioColumn displays a column of radio buttons in a grid view.
* `RadioColumn` displays a column of radio buttons in a grid view.
*
* This column type is typically used when you need to allow users to select a single row from the grid.
* Each radio button in the column shares the same name attribute, ensuring only one can be selected at a time.
*/
final class RadioColumn implements ColumnInterface
{
/**
* Creates a new RadioColumn instance.
* Creates a new `RadioColumn` instance.
*
* @param string|null $header The header cell content. If `null`, no header will be rendered.
* @param string|null $footer The footer cell content. If `null`, no footer will be rendered.
Expand Down
2 changes: 1 addition & 1 deletion src/Column/RadioColumnRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function array_key_exists;

/**
* RadioColumnRenderer handles the rendering of radio button columns in a grid.
* `RadioColumnRenderer` handles the rendering of radio button columns in a grid.
*
* @implements ColumnRendererInterface<RadioColumn>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Column/SerialColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Yiisoft\Yii\DataView\Column;

/**
* SerialColumn displays a column of sequential row numbers (1-based) in a grid view.
* `SerialColumn` displays a column of sequential row numbers (1-based) in a grid view.
*/
final class SerialColumn implements ColumnInterface
{
/**
* Creates a new SerialColumn instance.
* Creates a new `SerialColumn` instance.
*
* @param string|null $header The header cell content. If null, no header will be rendered.
* @param string|null $footer The footer cell content. If null, no footer will be rendered.
Expand Down
2 changes: 1 addition & 1 deletion src/Column/SerialColumnRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Yiisoft\Yii\DataView\Column\Base\HeaderContext;

/**
* SerialColumnRenderer handles the rendering of sequential row number columns in a grid.
* `SerialColumnRenderer` handles the rendering of sequential row number columns in a grid.
*
* @implements ColumnRendererInterface<SerialColumn>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Column/SortableColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface SortableColumnInterface
*
* @param ColumnInterface $column The column instance being rendered
*
* @return array<string, string> The properties that can be sorted by this column
* @return array The properties that can be sorted by this column
*
* @psalm-param TColumn $column
* @psalm-return array<string, string>
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/DataReaderNotSetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
/**
* Exception thrown when attempting to create a data view widget without setting a data reader.
*
* This exception is thrown in scenarios where a data view widget (such as GridView or ListView)
* This exception is thrown in scenarios where a data view widget (such as `GridView` or `ListView`)
* is instantiated without providing a required data reader component. The data reader is essential
* for the widget to access and iterate over the data that needs to be displayed.
*/
final class DataReaderNotSetException extends LogicException
{
/**
* Creates a new DataReaderNotSetException instance.
* Creates a new `DataReaderNotSetException` instance.
*
* The exception message indicates that widget creation failed due to
* a missing data reader component.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/UrlGeneratorNotSetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/**
* Exception thrown when attempting to create a widget that requires URL generation without a URL generator.
*
* This exception is thrown in scenarios where a widget (such as GridView or ListView) needs to generate
* This exception is thrown in scenarios where a widget (such as `GridView` or `ListView`) needs to generate
* URLs (e.g., for sorting, pagination, or filtering), but no URL generator is configured. The URL generator
* is essential for creating proper URLs that maintain the widget's state and functionality.
*/
final class UrlGeneratorNotSetException extends RuntimeException implements FriendlyExceptionInterface
{
/**
* Creates a new UrlGeneratorNotSetException instance.
* Creates a new `UrlGeneratorNotSetException` instance.
*
* @param string $message Custom error message. If empty, use the default message from {@see getName()}.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Field/DataField.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use Closure;

/**
* DataField represents a field configuration for {@see DetailView} widget.
* `DataField` represents a field configuration for {@see DetailView} widget.
*
* This class defines how a single field should be displayed in a {@see DetailView},
* including its label, value, and HTML attributes for both label and value elements.
*/
final class DataField
{
/**
* Creates a new DataField instance.
* Creates a new `DataField` instance.
*
* @param string $name Property name in the data object or key name in the data array.
* Optional if `$value` is set explicitly.
Expand Down
4 changes: 2 additions & 2 deletions src/ListItemContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Yiisoft\Yii\DataView;

/**
* ListItemContext provides contextual information about the current item being rendered in a ListView.
* `ListItemContext` provides contextual information about the current item being rendered in a `ListView`.
*/
final class ListItemContext
{
Expand All @@ -17,7 +17,7 @@ final class ListItemContext
* @param int $index The zero-based index of the data in the array. This represents the item's position
* in the overall dataset, starting from 0.
* @param ListView $widget The list view object that is rendering the current item. This provides access
* to the ListView instance for accessing widget configuration and methods.
* to the `ListView` instance for accessing widget configuration and methods.
*/
public function __construct(
public readonly array|object $data,
Expand Down
4 changes: 2 additions & 2 deletions src/Pagination/KeysetPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function render(): string
}

/**
* Renders a single pagination item (Previous or Next).
* Renders a single pagination item (previous or next).
*
* @param string|Stringable $label The item label.
* @param string|null $url The item URL, or null if disabled.
Expand Down Expand Up @@ -287,7 +287,7 @@ private function renderItem(string|Stringable $label, ?string $url, bool $isDisa
/**
* Gets the keyset paginator instance.
*
* @throws PaginatorNotSetException if paginator is not set.
* @throws PaginatorNotSetException If paginator is not set.
*
* @return KeysetPaginator The keyset paginator instance.
*/
Expand Down
Loading

0 comments on commit 32bef46

Please sign in to comment.