#44437 closed defect (bug) (fixed)
Invocation parameter types are not compatible with declared
Reported by: | subrataemfluence | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | has-patch |
Focuses: | docs | Cc: |
Description
In class-wp-rest-post-types-controller.php
the type of parameter $post_type
in function prepare_item_for_response
is declared as stdClass
.
<?php * @param stdClass $post_type Post type data. ... public function prepare_item_for_response( $post_type, $request ) { ... }
The function has been called twice in the class file:
<?php public function get_item( $request ) { $obj = get_post_type_object( $request['type'] ); ... $data = $this->prepare_item_for_response( $obj, $request ); }
and
<?php public function get_items( $request ) { ... foreach( get_post_types( array(), 'object' ) as $obj ) { ... } $post_type = $this->prepare_item_for_response( $obj, $request ); }
Since $obj
is a known type, i.e. WP_Post_Type
can we declare the parameter $post_type
type as WP_Post_Type
instead of stdClass
?
Also, the object of this class is used in wp-includes/rest-api.php
for registering route but the function in question is never invoked in the system separately.
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
Proposed patch