From 31d77186e0f486986bff8cb6ec84b028f6c6419c Mon Sep 17 00:00:00 2001 From: rldhont Date: Mon, 11 Apr 2022 13:56:21 +0200 Subject: [PATCH] Fix PHPStan in lizmap Service Controller --- .../lizmap/controllers/service.classic.php | 26 ++++- phpstan-baseline.neon | 100 ------------------ 2 files changed, 21 insertions(+), 105 deletions(-) diff --git a/lizmap/modules/lizmap/controllers/service.classic.php b/lizmap/modules/lizmap/controllers/service.classic.php index 7286012c20..90306d72fa 100644 --- a/lizmap/modules/lizmap/controllers/service.classic.php +++ b/lizmap/modules/lizmap/controllers/service.classic.php @@ -383,6 +383,7 @@ protected function GetCapabilities($ogcRequest) $service = $ogcRequest->param('service'); $result = $ogcRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -408,6 +409,7 @@ protected function GetContext($wmsRequest) $result = $wmsRequest->process(); // Return response + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -433,6 +435,7 @@ protected function GetSchemaExtension($wmsRequest) $result = $wmsRequest->process(); // Return response + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -451,7 +454,7 @@ protected function GetSchemaExtension($wmsRequest) * * @param WFSRequest|WMSRequest|WMTSRequest $wmsRequest * - * @return jResponseBinary image rendered by the Map Server + * @return jResponseBinary|jResponseXml image rendered by the Map Server or Service Exception */ protected function GetMap($wmsRequest) { @@ -506,6 +509,7 @@ protected function GetLegendGraphics($wmsRequest) { $result = $wmsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -539,6 +543,7 @@ protected function GetFeatureInfo($wmsRequest) ); jEvent::notify('LizLogItem', $eventParams); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -563,6 +568,7 @@ protected function GetPrint($wmsRequest) { $result = $wmsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -597,6 +603,7 @@ protected function GetPrintAtlas($wmsRequest) { $result = $wmsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -633,6 +640,7 @@ protected function GetStyles($wmsRequest) { $result = $wmsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -649,7 +657,7 @@ protected function GetStyles($wmsRequest) * @urlparam string $repository Lizmap Repository * @urlparam string $project Name of the project * - * @return jResponseJson JSON configuration file for the specified project + * @return jResponseJson|jResponseXml JSON configuration file for the specified project or Service Exception */ public function getProjectConfig() { @@ -659,6 +667,7 @@ public function getProjectConfig() return $this->serviceException(); } + /** @var jResponseJson $rep */ $rep = $this->getResponse('json'); $rep->data = $this->project->getUpdatedConfig(); @@ -671,7 +680,7 @@ public function getProjectConfig() * @urlparam string $repository Lizmap Repository * @urlparam string $project Name of the project * - * @return jResponseJson key/value JSON configuration file for the specified project + * @return jResponseJson|jResponseXml key/value JSON configuration file for the specified project or Service Exception */ public function getKeyValueConfig() { @@ -680,6 +689,7 @@ public function getKeyValueConfig() if (!$this->getServiceParameters()) { return $this->serviceException(); } + /** @var jResponseJson $rep */ $rep = $this->getResponse('json'); $rep->data = $this->project->getLayersLabeledFieldsConfig(); @@ -700,6 +710,7 @@ protected function GetFeature($wfsRequest) { $result = $wfsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->mimeType = $result->mime; $rep->doDownload = false; @@ -768,6 +779,7 @@ protected function DescribeFeatureType($wfsRequest) $result = $wfsRequest->process(); // Return response + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->setHttpStatus($result->code, \Lizmap\Request\Proxy::getHttpStatusMsg($result->code)); $rep->mimeType = $result->mime; @@ -785,7 +797,7 @@ protected function DescribeFeatureType($wfsRequest) * @urlparam string $project Name of the project : mandatory * @urlparam string $authid SRS or CRS authid like USER:* * - * @return jResponseText + * @return jResponseText|jResponseXml */ protected function GetProj4() { @@ -796,6 +808,7 @@ protected function GetProj4() } // Return response + /** @var jResponseText $rep */ $rep = $this->getResponse('text'); $content = $this->project->getProj4($this->iParam('authid')); if (!$content) { @@ -816,6 +829,7 @@ protected function GetTile($wmtsRequest) { $result = $wmtsRequest->process(); + /** @var jResponseBinary $rep */ $rep = $this->getResponse('binary'); $rep->mimeType = $result->mime; $rep->content = $result->data; @@ -868,7 +882,7 @@ private function _getSelectionToken($repository, $project, $typename, $ids) } /** - * @return jResponseJson + * @return jResponseJson|jResponseXml */ protected function getSelectionToken() { @@ -878,6 +892,7 @@ protected function getSelectionToken() } // Prepare response + /** @var jResponseJson $rep */ $rep = $this->getResponse('json'); // Get params @@ -923,6 +938,7 @@ protected function getFilterToken() } // Prepare response + /** @var jResponseJson $rep */ $rep = $this->getResponse('json'); // Get params diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dfd823c7c2..64eeccd512 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1325,106 +1325,6 @@ parameters: count: 2 path: lizmap/modules/lizmap/controllers/service.classic.php - - - message: "#^Method serviceCtrl\\:\\:DescribeFeatureType\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetCapabilities\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetContext\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetFeature\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 2 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetFeatureInfo\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetLegendGraphics\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetMap\\(\\) should return jResponseBinary but returns jResponseXml\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetPrint\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetPrintAtlas\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetProj4\\(\\) should return jResponseText but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetProj4\\(\\) should return jResponseText but returns jResponseXml\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetSchemaExtension\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetStyles\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:GetTile\\(\\) should return jResponseBinary but returns jResponse\\.$#" - count: 2 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getKeyValueConfig\\(\\) should return jResponseJson but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getKeyValueConfig\\(\\) should return jResponseJson but returns jResponseXml\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getProjectConfig\\(\\) should return jResponseJson but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getProjectConfig\\(\\) should return jResponseJson but returns jResponseXml\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getSelectionToken\\(\\) should return jResponseJson but returns jResponse\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - - - message: "#^Method serviceCtrl\\:\\:getSelectionToken\\(\\) should return jResponseJson but returns jResponseXml\\.$#" - count: 1 - path: lizmap/modules/lizmap/controllers/service.classic.php - - message: "#^Method serviceCtrl\\:\\:iParam\\(\\) should return string but returns null\\.$#" count: 1