[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/src/Common/Contracts/ -> WithArrayTransformationInterface.php (source)

   1  <?php
   2  
   3  declare (strict_types=1);
   4  namespace WordPress\AiClient\Common\Contracts;
   5  
   6  /**
   7   * Interface for objects that support array transformation.
   8   *
   9   * @since 0.1.0
  10   *
  11   * @template TArrayShape of array<string, mixed>
  12   */
  13  interface WithArrayTransformationInterface
  14  {
  15      /**
  16       * Converts the object to an array representation.
  17       *
  18       * @since 0.1.0
  19       *
  20       * @return TArrayShape The array representation.
  21       */
  22      public function toArray(): array;
  23      /**
  24       * Creates an instance from array data.
  25       *
  26       * @since 0.1.0
  27       *
  28       * @param TArrayShape $array The array data.
  29       * @return self<TArrayShape> The created instance.
  30       */
  31      public static function fromArray(array $array): self;
  32      /**
  33       * Checks if the array is a valid shape for this object.
  34       *
  35       * @since 0.1.0
  36       *
  37       * @param array<mixed> $array The array to check.
  38       * @return bool True if the array is a valid shape.
  39       * @phpstan-assert-if-true TArrayShape $array
  40       */
  41      public static function isArrayShape(array $array): bool;
  42  }


Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref