1 | <?php |
||
10 | class Writing_On_GitHub_Fetch_Client extends Writing_On_GitHub_Base_Client { |
||
11 | |||
12 | /** |
||
13 | * Compare a commit by sha with master from the GitHub API |
||
14 | * |
||
15 | * @param string $sha Sha for commit to retrieve. |
||
16 | * |
||
17 | * @return Writing_On_GitHub_File_Info[]|WP_Error |
||
|
|||
18 | */ |
||
19 | 1 | public function compare( $sha ) { |
|
20 | // https://api.github.com/repos/litefeel/testwpsync/compare/861f87e8851b8debb78db548269d29f8da4d94ac...master |
||
21 | 1 | $endpoint = $this->compare_endpoint(); |
|
22 | 1 | $branch = $this->branch(); |
|
23 | 1 | $data = $this->call( 'GET', "$endpoint/$sha...$branch" ); |
|
24 | |||
25 | 1 | if ( is_wp_error( $data ) ) { |
|
26 | return $data; |
||
27 | } |
||
28 | |||
29 | 1 | $files = array(); |
|
30 | 1 | foreach ($data->files as $file) { |
|
31 | 1 | $file->path = $file->filename; |
|
32 | 1 | $files[] = new Writing_On_GitHub_File_Info($file); |
|
33 | 1 | } |
|
34 | |||
35 | 1 | return $files; |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Calls the content API to get the post's contents and metadata |
||
40 | * |
||
41 | * Returns Object the response from the API |
||
42 | * |
||
43 | * @param Writing_On_GitHub_Post $post Post to retrieve remote contents for. |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | public function remote_contents( $post ) { |
||
50 | |||
51 | |||
52 | |||
53 | public function exists( $path ) { |
||
60 | |||
61 | /** |
||
62 | * Retrieves a tree by sha recursively from the GitHub API |
||
63 | * |
||
64 | * @param string $sha Commit sha to retrieve tree from. |
||
65 | * |
||
66 | * @return Writing_On_GitHub_File_Info[]|WP_Error |
||
67 | */ |
||
68 | 6 | public function tree_recursive( $sha = '_default' ) { |
|
94 | |||
95 | /** |
||
96 | * Retrieves the blob data for a given sha |
||
97 | * |
||
98 | * @param Writing_On_GitHub_File_Info $fileinfo |
||
99 | * |
||
100 | * @return Writing_On_GitHub_Blob|WP_Error |
||
101 | */ |
||
102 | 1 | public function blob( Writing_On_GitHub_File_Info $fileinfo ) { |
|
112 | |||
113 | /** |
||
114 | * Get blob by path |
||
115 | * @param string $path |
||
116 | * @return Writing_On_GitHub_Blob|WP_Error |
||
117 | */ |
||
118 | public function blob_by_path( $path ) { |
||
126 | } |
||
127 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.If the return type contains the type array, this check recommends the use of a more specific type like
String[]
orarray<String>
.