File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use WP_Error ;
6
6
use WP \OAuth2 ;
7
+ use WP \OAuth2 \Types \Type ;
7
8
8
9
class Authorization {
9
10
const LOGIN_ACTION = 'oauth2_authorize ' ;
@@ -26,6 +27,7 @@ public function handle_request() {
26
27
// Match type to a handler.
27
28
$ grant_types = OAuth2 \get_grant_types ();
28
29
if ( $ grant_types ) {
30
+ /** @var Type $type_handler */
29
31
foreach ( array_reverse ( $ grant_types ) as $ type_handler ) {
30
32
if ( $ type_handler ->get_response_type_code () === $ type ) {
31
33
$ handler = $ type_handler ;
Original file line number Diff line number Diff line change 9
9
10
10
namespace WP \OAuth2 ;
11
11
12
+ use WP \OAuth2 \Types \Type ;
12
13
use WP_REST_Response ;
13
14
14
15
bootstrap ();
@@ -63,7 +64,7 @@ function rest_oauth2_load_authorize_page() {
63
64
/**
64
65
* Get valid grant types.
65
66
*
66
- * @return array Map of grant type to handler object.
67
+ * @return Type[] Map of grant type to handler object.
67
68
*/
68
69
function get_grant_types () {
69
70
/**
@@ -73,9 +74,14 @@ function get_grant_types() {
73
74
* Note that additional grant types must follow the extension policy in the
74
75
* OAuth 2 specification.
75
76
*
76
- * @param array $grant_types Map of grant type to handler object.
77
+ * @param Type[] $grant_types Map of grant type to handler object.
77
78
*/
78
- return apply_filters ( 'oauth2.grant_types ' , array () );
79
+ $ grant_types = apply_filters ( 'oauth2.grant_types ' , array () );
80
+
81
+ return array_filter ( $ grant_types , function ( $ type ) {
82
+
83
+ return $ type instanceof Type;
84
+ } );
79
85
}
80
86
81
87
/**
You can’t perform that action at this time.
0 commit comments