Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .phpstan.dist.baselines/argument.type.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,6 @@
'count' => 1,
'path' => __DIR__ . '/../app/code/core/Mage/Api/Helper/Data.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Parameter #1 $path of function basename expects string, string|false given.',
'count' => 1,
'path' => __DIR__ . '/../app/code/core/Mage/Api/Helper/Data.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Parameter #1 $node of method Varien_Simplexml_Config::setXml() expects Varien_Simplexml_Element, Varien_Simplexml_Element|false given.',
'count' => 1,
Expand Down Expand Up @@ -1091,11 +1086,6 @@
'count' => 1,
'path' => __DIR__ . '/../app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Parameter #1 $path of function basename expects string, string|false given.',
'count' => 1,
'path' => __DIR__ . '/../app/code/core/Mage/Api2/Model/Route/ApiType.php',
];
$ignoreErrors[] = [
'rawMessage' => 'Parameter #1 $adminId of method Mage_Api2_Adminhtml_Api2_RoleController::_addUserToRole() expects int, int|string given.',
'count' => 1,
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Api/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public function getCacheId()
* @param bool $htmlSpecialChars
* @return string
* @throws Zend_Uri_Exception
* @SuppressWarnings("PHPMD.Superglobals")
*/
public function getServiceUrl($routePath = null, $routeParams = null, $htmlSpecialChars = false)
{
Expand All @@ -379,7 +380,8 @@ public function getServiceUrl($routePath = null, $routeParams = null, $htmlSpeci
$uri = Zend_Uri_Http::fromString($url);
$uri->setHost($request->getHttpHost());
if (!$urlModel->getRouteFrontName()) {
$uri->setPath('/' . trim($request->getBasePath() . '/' . basename(getenv('SCRIPT_FILENAME')), '/'));
$scriptFilename = (string) ($_SERVER['SCRIPT_FILENAME'] ?? $_SERVER['SCRIPT_NAME'] ?? '');
$uri->setPath('/' . trim($request->getBasePath() . '/' . basename($scriptFilename), '/'));
} else {
$uri->setPath($request->getBaseUrl() . $request->getPathInfo());
}
Expand Down
6 changes: 5 additions & 1 deletion app/code/core/Mage/Api2/Model/Route/ApiType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright For copyright and license information, read the COPYING.txt file.
* @link /COPYING.txt
Expand Down Expand Up @@ -30,6 +32,7 @@ class Mage_Api2_Model_Route_ApiType extends Mage_Api2_Model_Route_Abstract imple
* @param array $reqs Regular expression requirements for variables (keys as variable names)
* @param null|Zend_Translate $translator Translator to use for this instance
* @param mixed $locale
* @SuppressWarnings("PHPMD.Superglobals")
*/
public function __construct(
$route, // @phpstan-ignore constructor.unusedParameter
Expand All @@ -38,7 +41,8 @@ public function __construct(
?Zend_Translate $translator = null, // @phpstan-ignore constructor.unusedParameter
$locale = null // @phpstan-ignore constructor.unusedParameter
) {
$scriptFilename = (string) ($_SERVER['SCRIPT_FILENAME'] ?? $_SERVER['SCRIPT_NAME'] ?? '');
// phpcs:ignore Ecg.Security.ForbiddenFunction.Found
parent::__construct([Mage_Api2_Model_Route_Abstract::PARAM_ROUTE => str_replace('.php', '', basename(getenv('SCRIPT_FILENAME'))) . '/:api_type']);
parent::__construct([Mage_Api2_Model_Route_Abstract::PARAM_ROUTE => str_replace('.php', '', basename($scriptFilename)) . '/:api_type']);
}
}
Loading