Verified Commit 3e9f2844 authored by Dave Long's avatar Dave Long
Browse files

Issue #3542137 by mstrelan: Fix strict type issues in SchemaCheckTrait

parent 29f97557
Loading
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
use Drupal\Core\TypedData\Type\StringInterface;
use Drupal\Core\TypedData\Type\FloatInterface;
use Drupal\Core\TypedData\Type\IntegerInterface;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationInterface;

/**
 * Provides a trait for checking configuration schema.
@@ -109,10 +109,10 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co
      $violations = $this->schema->validate();
      $filtered_violations = array_filter(
        iterator_to_array($violations),
        fn(ConstraintViolation $v) => !static::isViolationForIgnoredPropertyPath($v),
        fn(ConstraintViolationInterface $v) => !static::isViolationForIgnoredPropertyPath($v),
      );
      $validation_errors = array_map(
        fn(ConstraintViolation $v) => sprintf("[%s] %s", $v->getPropertyPath(), (string) $v->getMessage()),
        fn(ConstraintViolationInterface $v) => sprintf("[%s] %s", $v->getPropertyPath(), (string) $v->getMessage()),
        $filtered_violations
      );
      // @todo Decide in https://www.drupal.org/project/drupal/issues/3395099 when/how to trigger deprecation errors or even failures for contrib modules.
@@ -128,14 +128,14 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co
  /**
   * Determines whether this violation is for an ignored Config property path.
   *
   * @param \Symfony\Component\Validator\ConstraintViolation $v
   * @param \Symfony\Component\Validator\ConstraintViolationInterface $v
   *   A validation constraint violation for a Config object.
   *
   * @return bool
   *   TRUE when the violation is for an ignored configuration property path,
   *   FALSE otherwise.
   */
  protected static function isViolationForIgnoredPropertyPath(ConstraintViolation $v): bool {
  protected static function isViolationForIgnoredPropertyPath(ConstraintViolationInterface $v): bool {
    // When the validated object is a config entity wrapped in a
    // ConfigEntityAdapter, some work is necessary to map from e.g.
    // `entity:comment_type` to the corresponding `comment.type.*`.