@@ -115,13 +115,11 @@ public function generatePluginApiAnnotations(string $pluginName, bool $writeToFi
115115 *
116116 * @param array[] $annotations Collection of generated annotations. It's an array of arrays containing the lines
117117 * which make up all the annotations which need to be written to file.
118- * @param string $filePath Full path of the file to be overwritten with the annotations.
119118 * @param string $pluginName Name of the plugin. E.g. TagManager
120119 *
121- * @return false|int Indicating how much was written to file.
122- * @see file_put_contents To explain the return value.
120+ * @return string The full string content of the generated annotations file.
123121 */
124- public function writeAnnotationsToFile (array $ annotations , string $ filePath , string $ pluginName )
122+ public function getContentForGeneratedAnnotationsFile (array $ annotations , string $ pluginName ): string
125123 {
126124 $ lines = [
127125 '<?php ' ,
@@ -145,8 +143,25 @@ public function writeAnnotationsToFile(array $annotations, string $filePath, str
145143 '} ' ,
146144 ]);
147145
146+ // Return the fully assembled content for the generated annotations file
147+ return implode (PHP_EOL , $ lines );
148+ }
149+
150+ /**
151+ * Write the collection of annotation lines to file, overwriting the file if it already exists.
152+ *
153+ * @param array[] $annotations Collection of generated annotations. It's an array of arrays containing the lines
154+ * which make up all the annotations which need to be written to file.
155+ * @param string $filePath Full path of the file to be overwritten with the annotations.
156+ * @param string $pluginName Name of the plugin. E.g. TagManager
157+ *
158+ * @return false|int Indicating how much was written to file.
159+ * @see file_put_contents To explain the return value.
160+ */
161+ protected function writeAnnotationsToFile (array $ annotations , string $ filePath , string $ pluginName )
162+ {
148163 // Create or overwrite the annotations file
149- return file_put_contents ($ filePath , implode ( PHP_EOL , $ lines ));
164+ return file_put_contents ($ filePath , $ this -> getContentForGeneratedAnnotationsFile ( $ annotations , $ pluginName ));
150165 }
151166
152167 /**
@@ -369,7 +384,11 @@ protected function determineParameters(array $rules, string $plugin, string $met
369384 }
370385
371386 $ paramsMetadata = Proxy::getInstance ()->getParametersListWithTypes (Request::getClassNameAPI ($ plugin ), $ method );
372- $ paramsInfo = $ this ->getParamInfoFromDocBlock ($ reflectionMethod ->getDocComment ());
387+ $ paramsInfo = [];
388+ $ docBlock = $ reflectionMethod ->getDocComment ();
389+ if (!empty ($ docBlock )) {
390+ $ paramsInfo = $ this ->getParamInfoFromDocBlock ($ docBlock );
391+ }
373392
374393 $ customParams = [];
375394 foreach ($ paramsMetadata as $ name => $ paramMetadata ) {
@@ -609,6 +628,7 @@ protected function getExampleIfAvailable(string $url, bool $useLocalToken = fals
609628 || stripos ($ response ['data ' ], '"result":"error" ' ) !== false
610629 || stripos ($ response ['data ' ], '<result /> ' ) !== false
611630 || trim ($ response ['data ' ]) === '[] '
631+ || (stripos ($ url , 'format=tsv ' ) !== false && trim ($ response ['data ' ]) === 'No data available ' )
612632 ) {
613633 return '' ;
614634 }
@@ -735,7 +755,11 @@ protected function determineResponses(array $rules, string $plugin, string $meth
735755
736756 // Try to determine the success response using the return type and/or doc-block return type
737757 $ returnType = $ reflectionMethod ->getReturnType ();
738- $ responseInfo = $ this ->getResponseInfoFromDocBlock ($ reflectionMethod ->getDocComment ());
758+ $ responseInfo = [];
759+ $ docBlock = $ reflectionMethod ->getDocComment ();
760+ if (!empty ($ docBlock )) {
761+ $ responseInfo = $ this ->getResponseInfoFromDocBlock ($ docBlock );
762+ }
739763 if (!empty ($ returnType ) && $ returnType ->isBuiltin ()) {
740764 $ responseInfo ['type ' ] = $ this ->getOpenApiTypeFromPhpType (strval ($ returnType ));
741765 }
0 commit comments