diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 29ebd3b..7e66eb5 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -123,9 +123,9 @@ * which the method should be invoked. * @param Drupal\Core\Entity\EntityInterface $entity * The fully formed $entity_type entity. - * @param mixed $a + * @param array|string $a * (optional) A parameter for the invoked method. Defaults to NULL. - * @param mixed $b + * @param array|string $b * (optional) A parameter for the invoked method. Defaults to NULL. * @param array $options * (optional) An associative array of additional options, with the following @@ -213,9 +213,9 @@ function field_invoke_method($method, $target_function, EntityInterface $entity, * which the method should be invoked. * @param array $entities * An array of entities, keyed by entity ID. - * @param mixed $a + * @param array|string $a * (optional) A parameter for the invoked method. Defaults to NULL. - * @param mixed $b + * @param array|string $b * (optional) A parameter for the invoked method. Defaults to NULL. * @param $options * (optional) An associative array of additional options, with the following @@ -717,9 +717,12 @@ function _field_invoke_widget_target() { /** * Defines a 'target function' for field_invoke_method(). * - * Used to invoke methods on an instance's formatter. + * Used to invoke methods on an instance's formatter. + * Here we are using closure. 'use' is employed to use variables outside closure. + * use is always early binding implying that the variable values are just + * copied and modifying it inside the closure has no external effect. * - * @param mixed $display + * @param string|array $display * Can be either: * - The name of a view mode. * - An array of display properties, as found in @@ -729,6 +732,7 @@ function _field_invoke_widget_target() { * A 'target function' for field_invoke_method(). */ function _field_invoke_formatter_target($display) { + //the anonymous function is made to use the external variable $display employing 'use' return function ($instance) use ($display) { return $instance->getFormatter($display); }; diff --git a/core/modules/field/lib/Drupal/field/FieldInstance.php b/core/modules/field/lib/Drupal/field/FieldInstance.php index a1e7a4f..9547333 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/FieldInstance.php @@ -77,7 +77,7 @@ public function getWidget() { /** * Returns a Formatter plugin for the instance. * - * @param mixed $display_properties + * @param array|string $display_properties * Can be either: * - The name of a view mode. * - An array of display properties, as found in the 'display' entry of