Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parameters:
path: src/Listener/ViewListener.php

-
message: '#^Parameter \#1 \$field of method CrudView\\Listener\\ViewListener\:\:_deriveFieldFromContext\(\) expects string, list\<string\>\|string\|null given\.$#'
message: '#^Parameter \#1 \$field of method CrudView\\Listener\\ViewListener\:\:_deriveFieldFromContext\(\) expects string, array\<string\>\|string\|null given\.$#'
identifier: argument.type
count: 1
path: src/Listener/ViewListener.php
Expand Down
1 change: 0 additions & 1 deletion src/Breadcrumb/ActiveBreadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ActiveBreadcrumb extends Breadcrumb
/**
* // phpcs:ignore
* @inheritDoc
* @psalm-suppress MissingParamType
*/
public function __construct(string|array $title, string|array|null $url = null, array $options = [])
{
Expand Down
18 changes: 6 additions & 12 deletions src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ViewListener extends BaseListener
*
* @param \Cake\Event\EventInterface $event Event.
* @return void
* @psalm-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
* @phpstan-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
*/
public function beforeFind(EventInterface $event): void
{
Expand All @@ -63,7 +63,7 @@ public function beforeFind(EventInterface $event): void
*
* @param \Cake\Event\EventInterface $event Event.
* @return void
* @psalm-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
* @phpstan-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
*/
public function beforePaginate(EventInterface $event): void
{
Expand All @@ -84,7 +84,7 @@ public function beforePaginate(EventInterface $event): void
*
* @param \Cake\Event\EventInterface $event Event.
* @return void
* @psalm-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
* @phpstan-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
*/
public function beforeRender(EventInterface $event): void
{
Expand All @@ -96,7 +96,6 @@ public function beforeRender(EventInterface $event): void
$this->_entity = $event->getSubject()->entity;
}

/** @psalm-suppress RedundantPropertyInitializationCheck */
if (!isset($this->associations)) {
$this->associations = $this->_associations(array_keys($this->_getRelatedModels()));
}
Expand Down Expand Up @@ -134,12 +133,11 @@ public function beforeRender(EventInterface $event): void
*
* @param \Cake\Event\EventInterface $event Event.
* @return void
* @psalm-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
* @phpstan-param \Cake\Event\EventInterface<\Crud\Event\Subject> $event
*/
public function setFlash(EventInterface $event): void
{
unset($event->getSubject()->params['class']);
/** @psalm-suppress UndefinedPropertyAssignment */
$event->getSubject()->element = ltrim($event->getSubject()->type);
}

Expand Down Expand Up @@ -181,11 +179,11 @@ protected function _getPageTitle(): string
$displayFieldValue === null
|| $this->_model()->getDisplayField() === $this->_model()->getPrimaryKey()
) {
/** @psalm-var string $primaryKeyValue */
/** @phpstan-var string $primaryKeyValue */
return sprintf('%s %s #%s', $actionName, $controllerName, $primaryKeyValue);
}

/** @psalm-var string $primaryKeyValue */
/** @phpstan-var string $primaryKeyValue */
return sprintf('%s %s #%s: %s', $actionName, $controllerName, $primaryKeyValue, $displayFieldValue);
}

Expand Down Expand Up @@ -410,9 +408,7 @@ protected function _getControllerActions(): array
}

foreach ($actionBlacklist as $actionName) {
/** @psalm-suppress EmptyArrayAccess */
unset($table[$actionName]);
/** @psalm-suppress EmptyArrayAccess */
unset($entity[$actionName]);
}

Expand Down Expand Up @@ -440,7 +436,6 @@ protected function _getControllerActionConfiguration(string $actionName, array $
if ($this->_crud()->isActionMapped($realAction)) {
$action = $this->_action($realAction);
$class = get_class($action);
/** @psalm-suppress PossiblyFalseOperand */
$class = substr($class, strrpos($class, '\\') + 1);

if ($class === 'DeleteAction') {
Expand Down Expand Up @@ -591,7 +586,6 @@ protected function _primaryKeyValue(): array|string|int|null
*/
protected function _displayFieldValue(): string|int|null
{
/** @psalm-suppress PossiblyInvalidArgument */
return $this->_deriveFieldFromContext($this->_model()->getDisplayField());
}

Expand Down
2 changes: 0 additions & 2 deletions src/Listener/ViewSearchListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public function fields(): array
$input['class'] = 'autocomplete';
}

/** @psalm-suppress PossiblyUndefinedArrayOffset */
if (
!empty($input['class'])
&& strpos($input['class'], 'autocomplete') !== false
Expand All @@ -156,7 +155,6 @@ public function fields(): array
$input['options'][$input['value']] = $input['value'];
}

/** @psalm-suppress PossiblyInvalidOperand */
$input += [
'data-input-type' => 'text',
'data-tags' => 'true',
Expand Down
1 change: 0 additions & 1 deletion src/View/Cell/TablesListCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function display(?array $tables = null, ?array $blacklist = null): void
$tables = $schema->listTables();
sort($tables);

/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!empty($blacklist)) {
$tables = array_diff($tables, $blacklist);
}
Expand Down
2 changes: 0 additions & 2 deletions src/View/Helper/CrudViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public function introspect(string $field, mixed $value, array $options = []): ar

$fieldFormatters = $this->getConfig('fieldFormatters');
if (isset($fieldFormatters[$type])) {
/** @psalm-suppress PossiblyNullArrayOffset */
if (is_callable($fieldFormatters[$type])) {
return $fieldFormatters[$type](
$field,
Expand All @@ -166,7 +165,6 @@ public function introspect(string $field, mixed $value, array $options = []): ar
);
}

/** @psalm-suppress PossiblyNullArrayOffset */
return $this->{$fieldFormatters[$type]}($field, $value, $options);
}

Expand Down
2 changes: 0 additions & 2 deletions src/View/Widget/DateTimeWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public function render(array $data, ContextInterface $context): string

$clearIcon = $this->clearIcon;
$toggleIcon = $this->calendarIcon;
/** @psalm-suppress PossiblyUndefinedArrayOffset */
if (isset($datetimePicker['iconClass'])) {
$toggleIcon = $datetimePicker['iconClass'];
unset($datetimePicker['iconClass']);
Expand Down Expand Up @@ -155,7 +154,6 @@ public function render(array $data, ContextInterface $context): string
return $input;
}

/** @psalm-suppress PossiblyInvalidArrayOffset */
return $this->_templates->format('datetimePicker', [
'input' => $input,
'toggleIcon' => $toggleIcon,
Expand Down
11 changes: 11 additions & 0 deletions templates/element/action-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
?>

<?php foreach ($groups as $key => $group) : ?>
<?php
if (count($group) === 1) {
$subaction = key($group);
if (is_numeric($subaction)) {
$subaction = $group[$subaction];
}

echo $this->element('action-button', ['config' => $links[$subaction]]);
continue;
}
?>
<div class='btn-group' role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<?= $key ?>
Expand Down
Loading