Skip to content
Snippets Groups Projects
Commit 89773d1a authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2092265 by andypost, Xano, amateescu: Fix type-hinting for FieldInfo methods.

parent c3924101
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -71,7 +71,7 @@ class FieldInfo { ...@@ -71,7 +71,7 @@ class FieldInfo {
/** /**
* List of $field structures keyed by ID. Includes deleted fields. * List of $field structures keyed by ID. Includes deleted fields.
* *
* @var array * @var \Drupal\field\FieldInterface[]
*/ */
protected $fieldsById = array(); protected $fieldsById = array();
...@@ -166,7 +166,7 @@ public function flush() { ...@@ -166,7 +166,7 @@ public function flush() {
/** /**
* Collects a lightweight map of fields across bundles. * Collects a lightweight map of fields across bundles.
* *
* @return * @return array
* An array keyed by entity type. Each value is an array which keys are * An array keyed by entity type. Each value is an array which keys are
* field names and value is an array with two entries: * field names and value is an array with two entries:
* - type: The field type. * - type: The field type.
...@@ -218,8 +218,8 @@ public function getFieldMap() { ...@@ -218,8 +218,8 @@ public function getFieldMap() {
/** /**
* Returns all active fields, including deleted ones. * Returns all active fields, including deleted ones.
* *
* @return * @return \Drupal\field\FieldInterface[]
* An array of field definitions, keyed by field ID. * An array of field entities, keyed by field ID.
*/ */
public function getFields() { public function getFields() {
// Read from the "static" cache. // Read from the "static" cache.
...@@ -256,10 +256,10 @@ public function getFields() { ...@@ -256,10 +256,10 @@ public function getFields() {
/** /**
* Retrieves all active, non-deleted instances definitions. * Retrieves all active, non-deleted instances definitions.
* *
* @param $entity_type * @param string $entity_type
* (optional) The entity type. * (optional) The entity type.
* *
* @return * @return array
* If $entity_type is not set, all instances keyed by entity type and bundle * If $entity_type is not set, all instances keyed by entity type and bundle
* name. If $entity_type is set, all instances for that entity type, keyed * name. If $entity_type is set, all instances for that entity type, keyed
* by bundle name. * by bundle name.
...@@ -309,7 +309,7 @@ public function getInstances($entity_type = NULL) { ...@@ -309,7 +309,7 @@ public function getInstances($entity_type = NULL) {
* @param string $field_name * @param string $field_name
* The field name. * The field name.
* *
* @return * @return \Drupal\field\FieldInterface|null
* The field definition, or NULL if no field was found. * The field definition, or NULL if no field was found.
*/ */
public function getField($entity_type, $field_name) { public function getField($entity_type, $field_name) {
...@@ -340,15 +340,15 @@ public function getField($entity_type, $field_name) { ...@@ -340,15 +340,15 @@ public function getField($entity_type, $field_name) {
} }
/** /**
* Returns a field definition from a field ID. * Returns a field entity from a field ID.
* *
* This method only retrieves active fields, deleted or not. * This method only retrieves active fields, deleted or not.
* *
* @param $field_id * @param string $field_id
* The field ID. * The field ID.
* *
* @return * @return \Drupal\field\FieldInterface|null
* The field definition, or NULL if no field was found. * The field entity, or NULL if no field was found.
*/ */
public function getFieldById($field_id) { public function getFieldById($field_id) {
// Read from the "static" cache. // Read from the "static" cache.
...@@ -386,13 +386,13 @@ public function getFieldById($field_id) { ...@@ -386,13 +386,13 @@ public function getFieldById($field_id) {
* The function also populates the corresponding field definitions in the * The function also populates the corresponding field definitions in the
* "static" cache. * "static" cache.
* *
* @param $entity_type * @param string $entity_type
* The entity type. * The entity type.
* @param $bundle * @param string $bundle
* The bundle name. * The bundle name.
* *
* @return * @return \Drupal\field\FieldInstanceInterface[]
* The array of instance definitions, keyed by field name. * An array of field instance entities, keyed by field name.
*/ */
public function getBundleInstances($entity_type, $bundle) { public function getBundleInstances($entity_type, $bundle) {
// Read from the "static" cache. // Read from the "static" cache.
...@@ -496,7 +496,7 @@ public function getBundleInstances($entity_type, $bundle) { ...@@ -496,7 +496,7 @@ public function getBundleInstances($entity_type, $bundle) {
} }
/** /**
* Returns an array of instance data for a specific field and bundle. * Returns a field instance.
* *
* @param string $entity_type * @param string $entity_type
* The entity type for the instance. * The entity type for the instance.
...@@ -505,9 +505,8 @@ public function getBundleInstances($entity_type, $bundle) { ...@@ -505,9 +505,8 @@ public function getBundleInstances($entity_type, $bundle) {
* @param string $field_name * @param string $field_name
* The field name for the instance. * The field name for the instance.
* *
* @return array * @return \Drupal\field\FieldInstanceInterface|null
* An associative array of instance data for the specific field and bundle; * The field instance entity, or NULL if it does not exist.
* NULL if the instance does not exist.
*/ */
function getInstance($entity_type, $bundle, $field_name) { function getInstance($entity_type, $bundle, $field_name) {
$info = $this->getBundleInstances($entity_type, $bundle); $info = $this->getBundleInstances($entity_type, $bundle);
...@@ -519,12 +518,12 @@ function getInstance($entity_type, $bundle, $field_name) { ...@@ -519,12 +518,12 @@ function getInstance($entity_type, $bundle, $field_name) {
/** /**
* Retrieves the "extra fields" for a bundle. * Retrieves the "extra fields" for a bundle.
* *
* @param $entity_type * @param string $entity_type
* The entity type. * The entity type.
* @param $bundle * @param string $bundle
* The bundle name. * The bundle name.
* *
* @return * @return array
* The array of extra fields. * The array of extra fields.
*/ */
public function getBundleExtraFields($entity_type, $bundle) { public function getBundleExtraFields($entity_type, $bundle) {
...@@ -555,13 +554,13 @@ public function getBundleExtraFields($entity_type, $bundle) { ...@@ -555,13 +554,13 @@ public function getBundleExtraFields($entity_type, $bundle) {
} }
/** /**
* Prepares a field definition for the current run-time context. * Prepares a field for the current run-time context.
* *
* @param $field * @param \Drupal\field\FieldInterface $field
* The raw field structure as read from the database. * The field entity to update.
* *
* @return * @return \Drupal\field\FieldInterface
* The field definition completed for the current runtime context. * The field that was prepared.
*/ */
public function prepareField(FieldInterface $field) { public function prepareField(FieldInterface $field) {
// Make sure all expected field settings are present. // Make sure all expected field settings are present.
...@@ -571,13 +570,13 @@ public function prepareField(FieldInterface $field) { ...@@ -571,13 +570,13 @@ public function prepareField(FieldInterface $field) {
} }
/** /**
* Prepares an instance definition for the current run-time context. * Prepares a field instance for the current run-time context.
* *
* @param \Drupal\field\FieldInstanceInterface $instance * @param \Drupal\field\FieldInstanceInterface $instance
* The instance definition. * The field instance entity to prepare.
* *
* @return * @return \Drupal\field\FieldInstanceInterface
* The field instance array completed for the current runtime context. * The field instance that was prepared.
*/ */
public function prepareInstance(FieldInstanceInterface $instance) { public function prepareInstance(FieldInstanceInterface $instance) {
// Make sure all expected instance settings are present. // Make sure all expected instance settings are present.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment