Verified Commit 7a6ed735 authored by Alex Pott's avatar Alex Pott
Browse files

docs: #3618622 Some cleanup related to OrderOperation for hooks

By: donquixote
By: charlliequadros
By: nicxvan
By: quietone
By: alexpott
(cherry picked from commit cc816cf5)
parent b0ae7c15
Loading
Loading
Loading
Loading
Loading
−6
Changes for core/.phpstan-baseline.php: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -9067,12 +9067,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Extension/ModuleHandler.php',
];
$ignoreErrors[] = [
	'message' => '#^PHPDoc tag @param has invalid value \\(array\\<string, list\\<string\\>\\>\\)\\: Unexpected token "\\\\n   ", expected variable at offset 90 on line 4$#',
	'identifier' => 'phpDoc.parseError',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Extension/ModuleHandler.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Extension\\\\ModuleHandlerInterface\\:\\:alter\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+1 −1
Changes for core/lib/Drupal/Core/Extension/ModuleHandler.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ class ModuleHandler implements ModuleHandlerInterface {
  /**
   * Ordering rules by hook name, packed.
   *
   * @param array<string, list<string>>
   * @var array<string, list<array{bool, array}>>
   */
  protected array $packedOrderOperations = [];

+5 −4
Changes for core/lib/Drupal/Core/Hook/OrderOperation/OrderOperation.php: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ abstract public function identify(): string;
  /**
   * Converts the operation to a structure that can be stored in the container.
   *
   * @return array
   * @return array{bool, array}
   *   Packed operation.
   */
  final public function pack(): array {
@@ -56,7 +56,7 @@ final public function pack(): array {
  /**
   * Converts the stored operation to objects that can apply ordering rules.
   *
   * @param array $packed_operation
   * @param array{bool, array} $packed_operation
   *   Packed operation.
   *
   * @return self
@@ -64,8 +64,9 @@ final public function pack(): array {
   */
  final public static function unpack(array $packed_operation): self {
    [$is_before_or_after, $args] = $packed_operation;
    $class = $is_before_or_after ? BeforeOrAfter::class : FirstOrLast::class;
    return new $class(...$args);
    return $is_before_or_after
      ? new BeforeOrAfter(...$args)
      : new FirstOrLast(...$args);
  }

}