Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book module support: keys optional; bid can be new or FALSE; add original_bid, parent_depth_limit. #593

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
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
36 changes: 19 additions & 17 deletions stubs/Drupal/node/NodeInterface.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ use Drupal\Core\Entity\ContentEntityInterface;

/**
* @phpstan-type BookData array{
* nid: int|numeric-string,
* bid: int|numeric-string,
* pid: int|numeric-string,
* has_children: int|numeric-string|bool,
* weight: int|numeric-string,
* depth: int|numeric-string,
* p1: int|numeric-string,
* p2: int|numeric-string,
* p3: int|numeric-string,
* p4: int|numeric-string,
* p5: int|numeric-string,
* p6: int|numeric-string,
* p7: int|numeric-string,
* p8: int|numeric-string,
* p9: int|numeric-string,
* link_path: string,
* link_title: string,
* "nid"?: int|numeric-string,
* "bid"?: int|'new'|numeric-string|false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I learned: you can provide valid string values to act as an enum!

* "original_bid"?: int|numeric-string,
* "pid"?: int|numeric-string,
* "parent_depth_limit"?: int|numeric-string,
* "has_children"?: int|numeric-string|bool,
* "weight"?: int|numeric-string,
* "depth"?: int|numeric-string,
* "p1"?: int|numeric-string,
* "p2"?: int|numeric-string,
* "p3"?: int|numeric-string,
* "p4"?: int|numeric-string,
* "p5"?: int|numeric-string,
* "p6"?: int|numeric-string,
* "p7"?: int|numeric-string,
* "p8"?: int|numeric-string,
* "p9"?: int|numeric-string,
* "link_path"?: string,
* "link_title"?: string,
* }
*
* @property BookData $book
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Type/data/book-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
use function PHPStan\Testing\assertType;

$node = Node::create(['type' => 'book']);
assertType('array{nid: int|numeric-string, bid: int|numeric-string, pid: int|numeric-string, has_children: bool|int|numeric-string, weight: int|numeric-string, depth: int|numeric-string, p1: int|numeric-string, p2: int|numeric-string, p3: int|numeric-string, p4: int|numeric-string, p5: int|numeric-string, p6: int|numeric-string, p7: int|numeric-string, p8: int|numeric-string, p9: int|numeric-string, link_path: string, link_title: string}', $node->book);
assertType('array{nid?: int|numeric-string, bid?: \'new\'|int|numeric-string|false, original_bid?: int|numeric-string, pid?: int|numeric-string, parent_depth_limit?: int|numeric-string, has_children?: bool|int|numeric-string, weight?: int|numeric-string, depth?: int|numeric-string, p1?: int|numeric-string, p2?: int|numeric-string, p3?: int|numeric-string, p4?: int|numeric-string, p5?: int|numeric-string, p6?: int|numeric-string, p7?: int|numeric-string, p8?: int|numeric-string, p9?: int|numeric-string, link_path?: string, link_title?: string}', $node->book);