File tree Expand file tree Collapse file tree 4 files changed +26
-21
lines changed
Expand file tree Collapse file tree 4 files changed +26
-21
lines changed Original file line number Diff line number Diff line change 39433943 <code ><![CDATA[ ArrayCache]]> </code >
39443944 <code ><![CDATA[ ArrayCache]]> </code >
39453945 </InvalidClass >
3946- <InvalidReturnStatement >
3947- <code ><![CDATA[ $response->getBody()]]> </code >
3948- </InvalidReturnStatement >
3949- <InvalidReturnType >
3950- <code ><![CDATA[ fopen]]> </code >
3951- </InvalidReturnType >
39523946 </file >
39533947 <file src =" lib/private/Files/Storage/Local.php" >
39543948 <TypeDoesNotContainNull >
41974191 </ImplementedReturnTypeMismatch >
41984192 </file >
41994193 <file src =" lib/private/Remote/Instance.php" >
4200- <InvalidReturnStatement >
4201- <code ><![CDATA[ $request->getBody()]]> </code >
4202- </InvalidReturnStatement >
4203- <InvalidReturnType >
4204- <code ><![CDATA[ bool|string]]> </code >
4205- </InvalidReturnType >
42064194 <InvalidScalarArgument >
42074195 <code ><![CDATA[ $response]]> </code >
42084196 </InvalidScalarArgument >
Original file line number Diff line number Diff line change @@ -350,7 +350,13 @@ public function fopen(string $path, string $mode) {
350350 }
351351 }
352352
353- return $ response ->getBody ();
353+ $ content = $ response ->getBody ();
354+
355+ if ($ content === null || is_string ($ content )) {
356+ return false ;
357+ }
358+
359+ return $ content ;
354360 case 'w ' :
355361 case 'wb ' :
356362 case 'a ' :
@@ -390,6 +396,8 @@ public function fopen(string $path, string $mode) {
390396 $ this ->writeBack ($ tmpFile , $ path );
391397 });
392398 }
399+
400+ return false ;
393401 }
394402
395403 public function writeBack (string $ tmpFile , string $ path ): void {
Original file line number Diff line number Diff line change @@ -123,7 +123,13 @@ private function getStatus() {
123123 private function downloadStatus ($ url ) {
124124 try {
125125 $ request = $ this ->clientService ->newClient ()->get ($ url );
126- return $ request ->getBody ();
126+ $ content = $ request ->getBody ();
127+
128+ // IResponse.getBody responds with null|resource if returning a stream response was requested.
129+ // As that's not the case here, we can just ignore the psalm warning by adding an assertion.
130+ assert (is_string ($ content ));
131+
132+ return $ content ;
127133 } catch (\Exception $ e ) {
128134 return false ;
129135 }
Original file line number Diff line number Diff line change @@ -105,17 +105,20 @@ public function check() {
105105 }
106106
107107 /**
108- * @codeCoverageIgnore
109- * @param string $url
110- * @return resource|string
111108 * @throws \Exception
112109 */
113- protected function getUrlContent ($ url ) {
114- $ client = $ this ->clientService ->newClient ();
115- $ response = $ client ->get ($ url , [
110+ protected function getUrlContent (string $ url ): string {
111+ $ response = $ this ->clientService ->newClient ()->get ($ url , [
116112 'timeout ' => 5 ,
117113 ]);
118- return $ response ->getBody ();
114+
115+ $ content = $ response ->getBody ();
116+
117+ // IResponse.getBody responds with null|resource if returning a stream response was requested.
118+ // As that's not the case here, we can just ignore the psalm warning by adding an assertion.
119+ assert (is_string ($ content ));
120+
121+ return $ content ;
119122 }
120123
121124 private function computeCategory (): int {
You can’t perform that action at this time.
0 commit comments