Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
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
5 changes: 3 additions & 2 deletions HTML/QuickForm2.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
);
parent::setId(empty($id) ? null : $id);
if (!isset($this->attributes['action'])) {
$this->attributes['action'] = $_SERVER['PHP_SELF'];

Check failure on line 78 in HTML/QuickForm2.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (ubuntu-latest, 7.1)

PossiblyUndefinedArrayOffset

HTML/QuickForm2.php:78:43: PossiblyUndefinedArrayOffset: Possibly undefined array key $_SERVER['PHP_SELF'] on array{APP_DEBUG?: bool|string, APP_ENV?: string, AUTH_TYPE?: non-empty-string, CONTENT_LENGTH?: string, CONTENT_TYPE?: string, DOCUMENT_ROOT?: non-empty-string, FCGI_ROLE?: non-empty-string, GATEWAY_INTERFACE?: non-empty-string, HOME?: non-empty-string, HTTPS?: string, HTTP_ACCEPT?: non-empty-string, HTTP_ACCEPT_CHARSET?: non-empty-string, HTTP_ACCEPT_ENCODING?: non-empty-string, HTTP_ACCEPT_LANGUAGE?: non-empty-string, HTTP_CACHE_CONTROL?: non-empty-string, HTTP_CDN_LOOP?: non-empty-string, HTTP_CF_CONNECTING_IP?: non-empty-string, HTTP_CF_IPCOUNTRY?: non-empty-string, HTTP_CF_VISITOR?: non-empty-string, HTTP_CLIENT_IP?: non-empty-string, HTTP_CONNECTION?: non-empty-string, HTTP_COOKIE?: non-empty-string, HTTP_DNT?: non-empty-string, HTTP_HOST?: non-empty-string, HTTP_PRIORITY?: non-empty-string, HTTP_REFERER?: non-empty-string, HTTP_SEC_CH_UA?: non-empty-string, HTTP_SEC_CH_UA_MOBILE?: non-empty-string, HTTP_SEC_CH_UA_PLATFORM?: non-empty-string, HTTP_SEC_FETCH_DEST?: non-empty-string, HTTP_SEC_FETCH_MODE?: non-empty-string, HTTP_SEC_FETCH_SITE?: non-empty-string, HTTP_SEC_FETCH_USER?: non-empty-string, HTTP_UPGRADE_INSECURE_REQUESTS?: non-empty-string, HTTP_USER_AGENT?: non-empty-string, HTTP_X_FORWARDED_FOR?: non-empty-string, HTTP_X_FORWARDED_PROTO?: non-empty-string, HTTP_X_REAL_IP?: non-empty-string, ORIG_PATH_INFO?: non-empty-string, PATH?: non-empty-string, PATH_INFO?: non-empty-string, PATH_TRANSLATED?: non-empty-string, PHP_AUTH_DIGEST?: non-empty-string, PHP_AUTH_PW?: non-empty-string, PHP_AUTH_USER?: non-empty-string, PHP_SELF?: non-empty-string, QUERY_STRING?: string, REDIRECT_REMOTE_USER?: non-empty-string, REDIRECT_STATUS?: non-empty-string, REMOTE_ADDR?: non-empty-string, REMOTE_HOST?: non-empty-string, REMOTE_PORT?: string, REMOTE_USER?: non-empty-string, REQUEST_METHOD?: non-empty-string, REQUEST_SCHEME?: non-empty-string, REQUEST_TIME?: int<1737367400, max>, REQUEST_TIME_FLOAT?: float, REQUEST_URI?: non-empty-string, SCRIPT_FILENAME?: non-empty-string, SCRIPT_NAME?: non-empty-string, SERVER_ADDR?: non-empty-string, SERVER_ADMIN?: non-empty-string, SERVER_NAME?: non-empty-string, SERVER_PORT?: non-empty-string, SERVER_PROTOCOL?: non-empty-string, SERVER_SIGNATURE?: non-empty-string, SERVER_SOFTWARE?: non-empty-string, USER?: non-empty-string, argc?: int<1, max>, argv?: non-empty-list<string>}<non-empty-string, string> (see https://psalm.dev/167)
}
if ($trackSubmit && isset($_REQUEST['_qf__' . $id]) ||
!$trackSubmit && ('get' == $method && !empty($_GET) ||
Expand Down Expand Up @@ -235,7 +235,7 @@
$renderer->setOption('group_errors', false);
$renderer->setOption('static_labels', true);

return $this->render($renderer)->toArray();

Check failure on line 238 in HTML/QuickForm2.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (ubuntu-latest, 7.1)

UndefinedMethod

HTML/QuickForm2.php:238:42: UndefinedMethod: Method HTML_QuickForm2_Renderer::toArray does not exist (see https://psalm.dev/022)
}

/**
Expand All @@ -256,8 +256,9 @@
if (!$elem->getError()) {
continue;
}
$label = $elem->getData()['label'];
$label = is_array($label) ? $label[0] : $label;
$elementData = $elem->getData();
$label = is_array($elementData) && array_key_exists('label', $elementData) ? $elementData['label'] : '';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$label = is_array($elementData) && array_key_exists('label', $elementData) ? $elementData['label'] : '';
$label = is_array($elementData) && array_key_exists('label', $elementData) ?? $elementData['label'];

Возможно и так будет работать. Кажется один из чекеров в проекте такое рекомендует. Не существенно.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут он не подойдет. Если бы было $elementData['label'] ?? '', то можно. А тут проверка один результат имеет, значение - другой

$label = is_array($label) ? $label[0] : $label;
if ($label) {
$error_messages[] = sprintf('%s: %s', $label, $elem->getError());
} else {
Expand Down
Loading