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: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ parameters:
ignoreErrors:
# Note paths are prefixed with ""*/" to wirk with inspections in PHPStorm because of:
# https://youtrack.jetbrains.com/issue/WI-63891/PHPStan-ignoreErrors-configuration-isnt-working-with-inspections
# Happens in classes implementing ContainerInjectionInterface::create()
- '/ constructor expects [^\s]+, object(\|null)? given.$/'
# Wrong phpdoc type hint in Drupal
- '/^Parameter #1 \$key of method Drupal\\Core\\Form\\FormStateInterface::hasTemporaryValue\(\) expects string, array<int\|string> given.$/'
-
Expand Down
11 changes: 7 additions & 4 deletions src/Form/AbstractJsonFormsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ abstract class AbstractJsonFormsForm extends FormBase {
* @return static
*/
public static function create(ContainerInterface $container) {
return new static($container->get(FormArrayFactoryInterface::class),
$container->get(FormValidatorInterface::class), $container->get(FormValidationMapperInterface::class));
return new static(
$container->get(FormArrayFactoryInterface::class),
$container->get(FormValidatorInterface::class),
$container->get(FormValidationMapperInterface::class)
);
}

public function __construct(
Expand Down Expand Up @@ -260,7 +263,7 @@ protected function doGetSubmittedData(FormStateInterface $formState): array {
*
* phpcs:disable Generic.Files.LineLength.TooLong
*/
private function determineLimitValidationErrors(FormStateInterface &$formState): ?array {
private function determineLimitValidationErrors(FormStateInterface $formState): ?array {
// While this element is being validated, it may be desired that some
// calls to \Drupal\Core\Form\FormStateInterface::setErrorByName() be
// suppressed and not result in a form error, so that a button that
Expand All @@ -284,7 +287,7 @@ private function determineLimitValidationErrors(FormStateInterface &$formState):
// setting the #limit_validation_errors property. For button element
// types, #limit_validation_errors defaults to FALSE, so that full
// validation is their default behavior.
elseif ($triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$formState->isSubmitted()) {
elseif (NULL !== $triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$formState->isSubmitted()) {
return [];
}
// As an extra security measure, explicitly turn off error suppression if
Expand Down
1 change: 1 addition & 0 deletions src/Form/Control/Callbacks/ArrayCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public static function removeItem(array &$form, FormStateInterface $formState):
private static function &getArrayForm(array &$form, array $triggeringElement): array {
$arrayParents = $triggeringElement['#array_parents'];
Assertion::isArray($arrayParents);
/** @var list<int|string> $arrayParents */
$propertyPath = $triggeringElement['#_controlPropertyPath'];
Assertion::isArray($propertyPath);

Expand Down
1 change: 0 additions & 1 deletion src/Form/Control/SelectArrayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function createFormArray(
if (!$definition->isRequired()) {
$form['#empty_value'] = '';
}
// @phpstan-ignore offsetAccess.nonOffsetAccessible
if (isset($form['#options']['']) && '' !== $form['#options']['']) {
$form['#empty_option'] = $form['#options'][''];
}
Expand Down