Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/PostData.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
}
}

public static function fromPost(\WP_Post $post): PostData
public static function fromPost(\WP_Post $post): static
{
return new (self::dataClass($post->post_type))(
id: $post->ID,
Expand All @@ -70,7 +70,7 @@ public static function fromPost(\WP_Post $post): PostData
);
}

public static function fromCorcel(Post $post): PostData
public static function fromCorcel(Post $post): static
{
return new (self::dataClass($post->post_type))(
id: $post->ID,
Expand All @@ -88,7 +88,7 @@ public static function fromCorcel(Post $post): PostData
}

/**
* @return class-string<PostData>
* @return class-string<static>
*/
private static function dataClass(string $postType): string
{
Expand All @@ -112,6 +112,7 @@ private static function dataClass(string $postType): string
throw new RuntimeException(sprintf('The class "%s" must extend %s.', $classFQN, PostData::class));
}

/** @var class-string<static> $classFQN */
return $classFQN;
}

Expand Down Expand Up @@ -298,7 +299,7 @@ public function isChild(): bool
return null !== $this->parent();
}

public function parent(): ?PostData
public function parent(): ?static
{
if (! is_post_type_hierarchical($this->postType) || ! is_numeric($this->id)) {
return null;
Expand Down