Skip to content

Commit

Permalink
Merge pull request #2905 from rldhont/phpstan-lizmap-service
Browse files Browse the repository at this point in the history
Fix PHPStan in lizmap Service Controller
  • Loading branch information
rldhont committed Apr 11, 2022
2 parents 8519f4f + 31d7718 commit 0efe909
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 105 deletions.
26 changes: 21 additions & 5 deletions lizmap/modules/lizmap/controllers/service.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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()
{
Expand All @@ -659,6 +667,7 @@ public function getProjectConfig()
return $this->serviceException();
}

/** @var jResponseJson $rep */
$rep = $this->getResponse('json');
$rep->data = $this->project->getUpdatedConfig();

Expand All @@ -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()
{
Expand All @@ -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();

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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()
{
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -868,7 +882,7 @@ private function _getSelectionToken($repository, $project, $typename, $ids)
}

/**
* @return jResponseJson
* @return jResponseJson|jResponseXml
*/
protected function getSelectionToken()
{
Expand All @@ -878,6 +892,7 @@ protected function getSelectionToken()
}

// Prepare response
/** @var jResponseJson $rep */
$rep = $this->getResponse('json');

// Get params
Expand Down Expand Up @@ -923,6 +938,7 @@ protected function getFilterToken()
}

// Prepare response
/** @var jResponseJson $rep */
$rep = $this->getResponse('json');

// Get params
Expand Down
100 changes: 0 additions & 100 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0efe909

Please sign in to comment.