Commit 0eec8f28 authored by catch's avatar catch
Browse files

fix: #3557372 \Drupal\Core\Field\BaseFieldDefinition::getPropertyDefinition()...

fix: #3557372 \Drupal\Core\Field\BaseFieldDefinition::getPropertyDefinition() causes deprecations on PHP 8.5

By: @alexpott
By: @smustgrave
parent adef6084
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -573,7 +573,10 @@ public function getOptionsProvider($property_name, FieldableEntityInterface $ent
  /**
   * {@inheritdoc}
   */
  public function getPropertyDefinition($name) {
  public function getPropertyDefinition(/* string */ $name) {
    if (!is_string($name)) {
      @trigger_error('Calling ' . __CLASS__ . '::getPropertyDefinition() with a non-string $name is deprecated in drupal:11.3.0 and throws an exception in drupal:12.0.0. See https://www.drupal.org/node/3557373', E_USER_DEPRECATED);
    }
    if (!isset($this->propertyDefinitions)) {
      $this->getPropertyDefinitions();
    }
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ public function getCardinality();
   * @return \Drupal\Core\TypedData\DataDefinitionInterface|null
   *   The definition of the property or NULL if the property does not exist.
   */
  public function getPropertyDefinition($name);
  public function getPropertyDefinition(/* string */ $name);

  /**
   * Gets an array of property definitions of contained properties.
+4 −1
Original line number Diff line number Diff line
@@ -780,7 +780,10 @@ public function getConstraint($constraint_name) {
  /**
   * {@inheritdoc}
   */
  public function getPropertyDefinition($name) {
  public function getPropertyDefinition(/* string */ $name) {
    if (!is_string($name)) {
      @trigger_error('Calling ' . __CLASS__ . '::getPropertyDefinition() with a non-string $name is deprecated in drupal:11.3.0 and throws an exception in drupal:12.0.0. See https://www.drupal.org/node/3557373', E_USER_DEPRECATED);
    }
    if (!isset($this->propertyDefinitions)) {
      $this->getPropertyDefinitions();
    }
+4 −2
Original line number Diff line number Diff line
@@ -492,9 +492,11 @@ protected function isReferenceFieldDefinition(FieldDefinitionInterface $field_de
    /** @var \Drupal\Core\Field\TypedData\FieldItemDataDefinition $item_definition */
    $item_definition = $field_definition->getItemDefinition();
    $main_property = $item_definition->getMainPropertyName();
    if ($main_property !== NULL) {
      $property_definition = $item_definition->getPropertyDefinition($main_property);
    }

    return $field_type_is_reference[$field_definition->getType()] = $property_definition instanceof DataReferenceTargetDefinition;
    return $field_type_is_reference[$field_definition->getType()] = isset($property_definition) && $property_definition instanceof DataReferenceTargetDefinition;
  }

  /**
+3 −0
Original line number Diff line number Diff line
@@ -3562,6 +3562,9 @@ protected static function isReferenceFieldDefinition(FieldDefinitionInterface $f
    /** @var \Drupal\Core\Field\TypedData\FieldItemDataDefinition $item_definition */
    $item_definition = $field_definition->getItemDefinition();
    $main_property = $item_definition->getMainPropertyName();
    if ($main_property === NULL) {
      return FALSE;
    }
    $property_definition = $item_definition->getPropertyDefinition($main_property);
    return $property_definition instanceof DataReferenceTargetDefinition;
  }
Loading